The Mother Board forums. Free tech support, motherboard ID, and more.
It is currently Wed Sep 19, 2018 11:17 am

All times are UTC - 8 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Forms and PHP
PostPosted: Thu Mar 17, 2005 4:20 pm 
Black Belt
Black Belt

Joined: Tue Oct 01, 2002 2:06 pm
Posts: 921
Location: Illinois
On my website I have a news submission form, with a dropdown box for a person to enter his/her name. Since I'm the only one who ever posts any news, I figured everything was working correctly. Well, today I added a new user and found out it is broken :oops:

This is what I have:

<select name="name">
  <option value="" selected>---Select---</option>
  <option value="Athaniel">Athaniel</option>
  <option value="Borador">Borador</option>
  <option value="Fayrwel">Fayrwel</option>
  <option value="Unsane">Unsane</option>
  <option value="Verdin">Verdin</option>

Now, originally I figured the value would end up in the name variable. Silly me, it doesn't seem to work that way. It seems the very last name in the list is always stored in the name variable. I've selected the other names and the last name ends up in the variable, I've even not selected a name and I get the same results.

Here's my PHP code:

  $date = date("l dS of F Y h:i:s A");
  if(empty($title) || empty($text) || empty($name))
    echo "You didn't completely fill in the form!  Please click the back button on your browser and make sure you filled out the name, article title, and news item sections.";
    echo "Thank you for submitting a news item!  Please return to the index page to see your post!";
    mysql_query("INSERT INTO news (name,date,title,text) VALUES ('$name','$date','$title','$text')");

The form method is POST by the way.

Edit: Nevermind! I fixed it! I changed <select name="name"> to <select name="toon"> and it works now! Seems you shouldn't assign the value "name" to a variable called "name" :wink:

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group