Jump to content

marccv1

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by marccv1

  1.  

    Here is an ugly, down and dirty way example. Not downloadable (copy and paste), zero formatting etc..

    <?php
    
    if (isset($_POST['submit']))
    {
        // grab your post values, do DB interactions etc.
        echo 'Form submitted successfuly.';
        exit(); // or redirect to another page
    
    }
    elseif (isset($_POST['xml']))
    {
        $name = $_POST['name'];
        $birthday = $_POST['birthday'];
    
        echo '<pre>';
        echo htmlspecialchars('<?xml version="1.0"?>');
        echo htmlspecialchars('<person>');
        echo htmlspecialchars("<name>$name</name>");
        echo htmlspecialchars("<birthday>$birthday</birthday>");
        echo htmlspecialchars('</person>');
        echo '</pre>';
        exit();
    }
    
    ?>
    <html>
    <head>
    </head>
    <body>
    <form name="form" method="post" action="index.php">
    Name:<input type="text" name="name"><br />
    Birthday:<input type="text" name="birthday"><br />
    <input type="submit" name="submit" value="submit">     
    <input type="submit" name="xml" value="export to xml">
    </form>
    </body>
    </html>
    
    

    thank you very much for this example.

  2. Hi! I need to make a little signup form that contains 2 textbox for name and birthday and 2 buttons for submit and export to xml. When the user clicks on the export to xml button, there must be an xml file containing the information entered by the user that can be downloaded. I'm not really familiar to php but can you give me an idea on how to make this possible ? thank you 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.