Jump to content

jess3333

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jess3333's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your suggestion. I will try it out. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Jess
  2. Hi All, I am just learning PHP and need help. I realize this may have been answered already, but I wasn't sure what to search for so I thought I should just post a new question. I found a tutorial processing forms (on another website) and copied the code (see below) because I need to do something similar for the website I am building. When I tried it out, it didn't work. (I tried to contact the person who wrote the tutorial but their email is not valid.) The problem is when I fill in the form and press the submit button, it is supposed to execute the "if ($submit)" statement, but it doesn't. The form just resets and the database does not get updated. Would you have any idea why it does not work? I am sure there are better ways of processing a form and I am open to suggestions but this is bugging me because I can't figure out why it won't work. Thanks for your time and help, it is very much appreciated. Cheers, Jess <?php if ($submit) { // process form $db = mysql_connect("localhost", "root"); mysql_select_db("mydb",$db); $sql = "INSERT INTO employees (first,last,address) VALUES ('$first','$last','$address')"; $result = mysql_query($sql); echo "Thank you! Information entered.\n"; } else{ // display form ?> <form method="post" action="<?php echo $PHP_SELF?>"> First name:<input type="Text" name="first"><br> Last name:<input type="Text" name="last"><br> Address:<input type="Text" name="address"><br> <input type="Submit" name="submit" value="Enter information"> </form> <?php } // end if ?>
×
×
  • 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.