Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need a very simple form submission script

    Hi everyone

    Could anyone point me in the direction of a REALLY SIMPLE php to mysql form submission script?

    Simply, it is for registering an email address and phone number (optional) into my database for membership of a club night.

    So i literally want 2 boxes, and they write to 2 columns in a mysql database.

    Does anyone have a code snippet or a recommendation of a good tutorial?
    I havent done any php for ages and im well out of the loop

    Gazz

  • #2
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    I wrote something quick for you, which might help you start off with.
    It's not perfect, but I think this is what you're looking for.

    PHP Code:
    <?php
    if($_POST['formsubmit']){
        
    $email $_POST['email'];
        
    $phone $_POST['phone'];
        
        
    // Error check. You could add more to this.
        // For example checking if phone number is supplied, and if it's only integers.
        // And if the e-mail address is valid.
        
    if(!$email){
            echo 
    "Please supply an e-mail address.";
        }else{
            
    $insertData mysql_query("INSERT INTO `table_name` (`email`,`phone`) VALUES ('".$email."','".$phone."')") or die(mysql_error());
            echo 
    "Thank you!";
        }
    }else{
        echo 
    "<form method=\"POST\">";
            echo 
    "E-mail: <input type=\"text\" name=\"email\" /><br />";
            echo 
    "Phone number: <input type=\"text\" name=\"phone\" /><br />";
            echo 
    "<input type=\"submit\" name=\"formsubmit\" value=\"Submit\" />";
        echo 
    "</form>";
    }
    ?>
    I only added a few lines of comments, feel free to ask, if you need any more help.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you for this, im going to try that out and see how it goes, my web server has expired tho so I gotta get that back online!!!

  • #4
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Of course you'd need a database for that example to work. And you'd want to sanitize that data.
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •