Jump to content

Juniorflip

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Posts posted by Juniorflip

  1. If I am going to do required field in php  when do I make the function happen.  On the next php or the current one. Here is my code

    [code]<html>
    <head>
    <body>
    <h4>EmailLauncher Note Form</h4>
    <form action="write.php" method="post"">
    Campaign: <input name="campaign" type="text" value=""/>
    <?php
    if(trim($_POST['campaign']) == "") {
      die("no value was entered");
    }
    ?>
    <select name="experience">
    <option>Good</option>
    <option>So So</option>
    <option>Bad</option>
    <option>Cancelled</option>
    </select>
    <br><br>
    <select name="note">
    <option>Yes</option>
    <option>No</option>
    <option>Supersave</option>

    </select><br><Br>
    Customer Lead Name: <input name="name" type="text" value=""/>

    <input type="submit" />
    </form>
    </body></html>[/code]

    However it automatically kill it right away.  Is there a way to have the function execute on button click before going to write.php
  2. I need to load a variable into an array here is my code so far

    [code]
    $ourFileName2 = $ourFileName;

    Function create_xml() {
    $files = array('header.xml',$ourFileName2,'footer.xml');

    foreach($files as $file)
    {
    $contents[] = file_get_contents($file);
    }

    $fp = fopen('new_file.xml','w+');
    fwrite($fp,join("\n",$contents));
    fclose($fp);

    }
    create_xml();[/code]
  3. Ok I am on the last part YAY!!!  I just can't figure this last one out.  if I put in the array the actual body name it work however if I put in a variable it doesn't here is the excerpt and the full php

    When I use this code it doesn't bring over the XXXXbody.xml
    [code]$ourFileName2 = $ourFileName;
    Function chmod_xml() {
    chmod('1610body.xml', 0777);  // octal; correct value of mode
    }
    chmod_xml();

    Function create_xml() {
    $files = array('header.xml',$ourFileName2,'footer.xml');

    foreach($files as $file)
    {
    $contents[] = file_get_contents($file);
    }

    $fp = fopen('new_file.xml','w+');
    fwrite($fp,join("\n",$contents));
    fclose($fp);

    }
    create_xml();
    [/code]

    However if I manual type it in it works!!!  any help would be appreciated
    [code]<?php

    /******START CODE EXTRACT******/
    if(!function_exists("file_get_contents"))
    {
        function file_get_contents($f = null)
        {
            if(is_null($f)) return null;

            return implode("", file($f));
        }
    }
    /*******END CODE EXTRACT*******/



    $ourFileName = $campaign."body.xml";

    if (file_exists($ourFileName)) {
      $fh = fopen($ourFileName, 'a');
    } else {
      $fh = fopen($ourFileName, 'w') or die("can't open file");
    }

    $record = "<record>";
    $campaignid = "<campaignid>";
    $experienceid = "<experience>";
    $noteid = "<note>";
    $nameid = "<name>";
    $record2 = "</record>";
    $campaignid2 = "</campaignid>";
    $experienceid2 = "</experience>";
    $noteid2 = "</note>";
    $nameid2 = "</name>";



    fwrite($fh, $record);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $campaignid);
    fwrite($fh, $campaign);
    fwrite($fh, $campaignid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $experienceid);
    fwrite($fh, $experience);
    fwrite($fh, $experienceid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $noteid);
    fwrite($fh, $note);
    fwrite($fh, $noteid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $nameid);
    fwrite($fh, $name);
    fwrite($fh, $nameid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $record2);
    fclose($fh);
    $ourFileName2 = $ourFileName;
    Function chmod_xml() {
    chmod('1610body.xml', 0777);  // octal; correct value of mode
    }
    chmod_xml();

    Function create_xml() {
    $files = array('header.xml','1610body.xml','footer.xml');

    foreach($files as $file)
    {
    $contents[] = file_get_contents($file);
    }

    $fp = fopen('new_file.xml','w+');
    fwrite($fp,join("\n",$contents));
    fclose($fp);

    }
    create_xml();


    ?>[/code]
  4. because I am trying to join the file to two other file to make an xml here is my source

    [code]<?php

    /******START CODE EXTRACT******/
    if(!function_exists("file_get_contents"))
    {
        function file_get_contents($f = null)
        {
            if(is_null($f)) return null;

            return implode("", file($f));
        }
    }
    /*******END CODE EXTRACT*******/



    $ourFileName = $campaign."body.xml";

    if (file_exists($ourFileName)) {
      $fh = fopen($ourFileName, 'a');
    } else {
      $fh = fopen($ourFileName, 'w') or die("can't open file");
    }

    $record = "<record>";
    $campaignid = "<campaignid>";
    $experienceid = "<experience>";
    $noteid = "<note>";
    $nameid = "<name>";
    $record2 = "</record>";
    $campaignid2 = "</campaignid>";
    $experienceid2 = "</experience>";
    $noteid2 = "</note>";
    $nameid2 = "</name>";



    fwrite($fh, $record);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $campaignid);
    fwrite($fh, $campaign);
    fwrite($fh, $campaignid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $experienceid);
    fwrite($fh, $experience);
    fwrite($fh, $experienceid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $noteid);
    fwrite($fh, $note);
    fwrite($fh, $noteid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $nameid);
    fwrite($fh, $name);
    fwrite($fh, $nameid2);
    fwrite($fh, "\n");
    fwrite($fh, "\n");
    fwrite($fh, $record2);
    fclose($fh);
    $ourFileName2 = $ourFileName;
    Function create_xml() {
    $files = array('header.xml',$ourFileName2,'footer.xml');

    foreach($files as $file)
    {
    $contents[] = file_get_contents($file);
    }

    $fp = fopen('new_file.xml','w+');
    fwrite($fp,join("\n",$contents));
    fclose($fp);

    }
    create_xml();


    ?>[/code]


    It will create XXXXbody.xml and it will create new_file.xml.  new_file.xml will have header and footer in it.  but it will not have body.xml in it.  I am wondering if because it can not access the file
  5. So if I wanted to make a function it would go like this

    [code]
    Function create_greet {
    $header = get_file_contents('header.txt');
    $body = get_file_contents('body.txt');
    $footer = get_file_contents('footer.txt');
    if ($header === false) die("Couldn't read header.txt\n");
    $greeting_fp = fopen('greeting.txt', 'w');
    fwrite($greeting_fp, $header);
    fwrite($greeting_fp, $body);
    fwrite($greeting_fp, $footer);
    fclose($greeting_fp);
    }
    create_greet();
    [/code]
  6. Hopefully this is a simple function to do but I am looking to join 3 external file and output to a single file

    example

    header.txt = hello
    body.txt = welcome
    footer.txt = goodbye

    I need a php function that will open all three text file and print the value to a new text file

    example

    greeting.txt = hello
                        welcome
                        goodbye

    Is this possible to do?

    Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.