Hi everyone hope all well. I am needing your valuable expertise in a problem i am having. I will try to explain below.
I have a form and inside of that form i have a "select a state" option:
<select name="State">
<option value="0" selected="selected">Select a State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
etc.....
</select>
When the customer selects a state and then clicks the forms submit button, i want them to get taken my mysql database and pull an ip address from the table relevant to what they choose.
I have created a table inside of phpmyadmin with two fields. the first is: state,varchar,30,primary the second is: ip,text
I then imported an csv file which populated it with the following format
state ip
AL 67.100.244.74
AK 68.20.131.135
AK 64.134.225.33
etc.......
So an example would be: customer fills out the form and selects Alabama as a state. They then submit the form and the form connects to the database where it sees the state Alabama (AL). It then collects the ip from the ip section releated to the ALbama section, and submits that to my email address along with the rest of the form information (name,email,etc...). It also needs to randomly choose an ip from Alabama because in the database i have Alabama (AL) multiple times, so it just chooses anyone of the Alabama ip's
I hope i am making sense
If you know how to do this or where i can find the info it would be much appreciated
Thanks for all your help
Ali
Thanks for all your help and sorry in the delay. Whenever i add that code to the page i get this error
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/b/o/l/boldbaba406/html/1stop/1vince/test1.php on line 3
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/b/o/l/boldbaba406/html/1stop/1vince/test1.php on line 3
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/b/o/l/boldbaba406/html/1stop/1vince/test1.php on line 4
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/b/o/l/boldbaba406/html/1stop/1vince/test1.php on line 5
I am probably doing something really stupid, but i can not see what. Any help would be great
Ali
I have created a table ... with two fields- have you created a third, auto-incrementing index field (primary key) as well? As a general rule every table should have one of these, no matter how simple - there are some exceptions, but they are few and far between...