afternoon all I'm setting up a contact page using this php script, would like to add a coutry dropdown list all an ip tracker where my clients are coming from can someone help us as i'm having problems putting it together..... PHP: <hmtl> <head> <title>Cuntact Us.</title> </head> <body> <form action="http://www.cyberdating.com.au/mailthanks.php" method="post"> Name: <input type="text" name="name"><br> E-mail Address: <input type="text" name = "email"><br> Phone Number: <input type="text" name="name"><br> Subject:<input type="text" name="Subject"><br> Topic:<textarea name="comments"></textarea><br> <input type="RADIO" name="Website" value="cyberdating"<br><br>Cyberdating</br> <input type="submit" value="Submit"> </form> <? function checkOK($field) { if (eregi("\r",$field) || eregi("\n",$field)){ die("Invalid Input!"); } $name=$_POST['name']; checkOK($name); $email=$_POST['email']; checkOK($email); $Phone number=$_POST['phone number']; checkOK($phonenumber); $country =$ROW['country']; $comments=$_POST['comments']; checkOK($comments); $to="[email protected]"; $message="$name just filled in your comments form. They said:\n$comments\n\nTheir e-mail address was: $email"; if(mail($to,"Comments From Your Site",$message,"From: $email\n")) { echo "Thankyou for choosing Cyberdating one of our Sales Representatives will contact you shortly, If you have any furtre questions please do not hessite to contact us."; } else { echo "There was a problem sending the mail. Please check that you filled in the form correctly."; } ?> </body> </html>
So you want a country dropdownlist, as well as hidden infos from an IP tracker? Well the first part is quite easy. Either you define your drowdown in the html stuff, or you define an array in the php code from which you generate the dropdown then. At the end you can use that array to verify the input, but you should add an extra field for countries you did no list: e.g. PHP: <?php $countries = array( 'yourinternalcountryname' => 'Countrnametheusersees' ); ?> <html> ... <!-- Generate pulldown --> <select size="1" name="country"> <option value="">Select your country</option> <?php while( list($k,$v) = each($countries) ) { echo "<option value=\"$k\">$v</option>\n"; } ?> </select> ... <?php /*** The "verifycode" ***/ if( !array_key_exists($_POST['country'], $countries) ) { //Your errormessage here } ?> The Clients IP thing you can read from the superglobal array $_SERVER. Don't know the element by now but just take a look at its structure, e.g. with the following code... PHP: <?php echo '<pre>'; var_dump($_SERVER); echo </pre>'; ?>
It is nearly the structure I postet.... the first part comes on the top, the pulldown stuff anywhere in your htmlform and the last thing shall be put where you check your values....
Not sure if i have done this right just quote me here also notiuce with the radio buttons seams to be checked. PHP: <hmtl> <head> <title>Cuntact Us.</title> </head> <body> <form action="http://www.cyberdating.com.au/mailthanks.php" method="post"> Name: <input type="text" name="name"><br> E-mail Address: <input type="text" name = "email"><br> Phone Number: <input type="text" name="name"><br> <select size="1" name="country"><option value="">-----Select your country-------</option> Subject: <input type="text" name="Subject"><br> Topic:<textarea name="comments"></textarea><br> <input type="RADIO" name="Website" value="cyberdating"<br><br>Cyberdating</br> <input type="RADIO" name="Mailing list" value="cyberdating Mailing List"<br><br>Cyberdating Mailing List</br> <input type="submit" value="Submit"> </form> <? function checkOK($field) { if (eregi("\r",$field) || eregi("\n",$field)){ die("Invalid Input!"); } $name=$_POST['name']; checkOK($name); $email=$_POST['email']; checkOK($email); $Phone number=$_POST['phone number']; checkOK($phonenumber); $country =$ROW['country']; $comments=$_POST['comments']; checkOK($comments); $to="[email protected]"; $message="$name just filled in your comments form. They said:\n$comments\n\nTheir e-mail address was: $email"; if(mail($to,"Comments From Your Site",$message,"From: $email\n")) { echo "Thankyou for choosing Cyberdating one of our Sales Representatives will contact you shortly, If you have any furtre questions please do not hessite to contact us."; } else { echo "There was a problem sending the mail. Please check that you filled in the form correctly."; } ?> </body> </html>
No you for got the whole rest. Definition of countries in the top, the php code with while to generate the selectbox as well as the synataxcheck....
The remote ip address is: $ip = $_SERVER["REMOTE_ADDR"]; and for verifiying the email address you chould use the check_email_mx function from this thise: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1316&lngWId=8