phpwiz Posted September 2, 2009 Share Posted September 2, 2009 ok i have made a code for a contest on my site. a pretty simple code but when they click submit it says "Please fill in all fields" when i did fill them all in here is the PHP code: <?php //include "BBcode.php"; //include "admin.php"; $connect = mysql_connect('localhost', 'root', '') or die("Couldnt connect"); mysql_select_db('members') or die("Couldn't find db"); $namecheck = mysql_query("SELECT IP FROM results"); $count = mysql_num_rows($namecheck); if ($_POST ['post']) { //get data $sprite = $_POST ['sprite']; $body = $_POST ['body']; $date = $_POST ['date']; $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; //check for existance if ($sprite&&$body) { $date = date ("Y-m-d"); //insert data $insert = mysql_query("INSERT INTO results VALUES ('$sprite','$body','$date','$IP')") or die (mysql_error ()); echo "You have successfully submitted the contest form! <a href='#'>View It?</a>"; } else { echo "Please fill out all fields<p>"; } } else { } ?> please help, thankyou. edit: here is the full code. <html> <head> <title>Pokemon Celestial :: Online RPG</title> <style type='text/css'> body { background-image: url('images/main_g.png'); background-repeat:repeat-x; font-family: arial; font-size: 8px; color: #000000; } input[type=text] { border: 1px solid green; background: #D6F4FF; } input[type=text]:hover { border: 1px solid red; background: #D6F4FF; } input[type=submit] { border: 1px solid black; background: #e1e1e1; } #container { width: 900px; font-family: arial; font-size: 8px; color: #000000; } .nav_top { background-image: url('images/nav_top.png'); font-size: 20px; text-align: center; height: 30px; width: 221px; position: relative; top: 3px; left: 180px; display: block; } .nav_topR { background-image: url('images/nav_top.png'); font-size: 20px; text-align: center; height: 30px; width: 221px; position: relative; top: 3px; left: 0px; float: right; } .border { border: 1px solid black; border-left: 1px solid black; border-top: 1px solid black; color: black; background: #000000; font-family: arial; border-right: 1px solid black; border-bottom: 1px solid black; } .padding { padding: 6px; } </style> </head> <body> <?php //include "BBcode.php"; //include "admin.php"; $connect = mysql_connect('localhost', 'root', '') or die("Couldnt connect"); mysql_select_db('members') or die("Couldn't find db"); $namecheck = mysql_query("SELECT IP FROM results"); $count = mysql_num_rows($namecheck); if ($_POST ['post']) { //get data $sprite = $_POST ['sprite']; $body = $_POST ['body']; $date = $_POST ['date']; $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; //check for existance if ($sprite&&$body) { $date = date ("Y-m-d"); //insert data $insert = mysql_query("INSERT INTO results VALUES ('$sprite','$body','$date','$IP')") or die (mysql_error ()); echo "You have successfully submitted the contest form! <a href='#'>View It?</a>"; } else { echo "Please fill out all fields<p>"; } } else { } ?> <center> <div id='container' align="center"> <!-- Start Banner --> <img src="http://localhost/splash/images/banner.png"></center> <!-- End banner --> <br><br><br><br> <center> <table class='border' width='700px'> <tr bgcolor='#FFFFC2'> <td colspan='2'> <center>.:: Spriter Contest! ::.</center> </td> </tr> <tr bgcolor='#FFFFFF'> <td colspan='2'> <div class='padding'><center>I am making a Spriter contest because i need help with the sprites, i am coding alone so it would be <b><u>VERY</u></b> hard to make all of the sprites aswell.</center></div> </td> </tr> <tr bgcolor='#FFFFFF'> <td> <center><div class='padding'> Rules:</div> </center> </td> <td> The Sprites have to be yours, and they <u>CANNOT</u> be fullbody recolors. you can decorate them as you please. and you can only submit an entry once! (i have your IP stored in the database). </td> </tr> <tr bgcolor='#FFFFFF'> <td> <center><div class='padding'>Prize(s):</div> </center> </td> <td> if you get chosen to become the spriter you will be on the staff list and you will get a Celestial Rayquaza one of the rarest pokemon inside of the RPG! and 300 Celestial Coins or CC for short. </td> </tr> <tr bgcolor='#FFFFFF'> <td colspan='2'> <center>Please enter the link to a sample of your sprites:</center> </td> </tr> <tr bgcolor='#FFFFFF'> <td colspan='2'> <div class='padding'> <center><input type='text' name='sprite' maxlength='200'></center> </div> </td> </tr> </tr> <tr bgcolor='#FFFFFF'> <td colspan='2'> <center>Please tell me why you would like to be a spriter for The Pokemon Celestial RPG:</center> </td> </tr> <tr bgcolor='#FFFFFF'> <td colspan='2'> <div class='padding'> <center><textarea rows='6' cols='35' name='body'></textarea></center> </div> </td> </tr> <tr bgcolor='#FFFFFF'> <td colspan='2'> <div class='padding'><center> <form action='' method='post'> <input type='submit' name='post' value='Submit'> </form> </center></div> </td> </tr> </table> </center> <br><br><br><br> <!-- start disclaimer --> <center><img src="images/disclaimer-celestial.png"></center> <!-- end disclaimer --> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/172784-help-me-please/ Share on other sites More sharing options...
Garethp Posted September 2, 2009 Share Posted September 2, 2009 Use if(preg_match('~[\w\d\.]~', $sprite) && preg_match('~[\w\d\.]~', $body)) instead if if($sprite&&$body) Your code just checks that they exist, mine checks that they contain either a lowercase, an uppercase, an underscore, a digit or a dot at the very least Link to comment https://forums.phpfreaks.com/topic/172784-help-me-please/#findComment-910705 Share on other sites More sharing options...
phpwiz Posted September 2, 2009 Author Share Posted September 2, 2009 Use if(preg_match('~[\w\d\.]~', $sprite) && preg_match('~[\w\d\.]~', $body)) instead if if($sprite&&$body) Your code just checks that they exist, mine checks that they contain either a lowercase, an uppercase, an underscore, a digit or a dot at the very least ok well that didn't help me with my problem. Link to comment https://forums.phpfreaks.com/topic/172784-help-me-please/#findComment-910708 Share on other sites More sharing options...
PFMaBiSmAd Posted September 2, 2009 Share Posted September 2, 2009 Your form starts and ends in the following three lines of code - <form action='' method='post'> <input type='submit' name='post' value='Submit'> </form> Nothing outside of those three lines of code is part of the form. You need to put the opening <form ....> tag before the start of any of the form fields. Link to comment https://forums.phpfreaks.com/topic/172784-help-me-please/#findComment-910716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.