BrotherBear Posted March 30, 2007 Share Posted March 30, 2007 hi all ! yesterday I couldn't put the error where I wanted now I can but now it show the error always everytime I press the send button even if the spaces are filled here's the code of the PHP and HTML <?php $con = mysql_connect("mysql1.100ws.com","johncoda_downloa","121212"); if (!$con) { die('Could not connect: ' . mysql_error()); } $Name = $_POST['Name']; $Age = $_POST['Age']; $Email = $_POST['Email']; $Comments = $_POST['Comments']; if ($Name==1) include ("processing.php"); if ($Name==0) $error = "Please fill the spaces completely"; include ("contactus.html"); exit(); mysql_select_db("johncoda_downloa", $con); $sql = mysql_query("INSERT INTO Customers (Name, Age, Email, Comments) VALUES('$Name', '$Age', '$Email', '$Comments')") or die (mysql_error()); ?> <html> <head> <meta http-equiv="Refresh" content="5;url=http://johncoda.freestarthost.com/thankyou.html"> </head> <body> </body> </html> form script <form action='processing.php' method='post'> <div class='name'>*Name:</div> <div class='namebox'><input type='text' name='Name' style='font-family:monotype corsiva; font-size:15px;' /><br><?"$error"?></div> <div class='age'>*Age:</div> <div class='agebox'><input type='text' name='Age' style='font-family:monotype corsiva; font-size:15px;' /><br></div> <div class='email'>*Email:</div> <div class='emailbox'><input type='text' name='Email' style='font-family:monotype corsiva; font-size:15px;' /><br></div> <div class='commentss'>*Comments:</div> <div class='commentssbox'><textarea name='Comments'>Write Your Message</textarea></div> <div class='submit'><input type='submit' value='Send!' /></div> </form> please help me, I want the rror to appear when necessary and the form to upload when everything's right BB Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/ Share on other sites More sharing options...
spfoonnewb Posted March 30, 2007 Share Posted March 30, 2007 Which error do you always get? I am not seeing how this would really work though: Since the name is probably never equal to "1".. probably something like "joe". <?php if ($Name==1) include ("processing.php"); if ($Name==0) $error = "Please fill the spaces completely"; include ("contactus.html"); exit(); ?> You may try: <?php if (!empty($Name)) { include ("processing.php"); } else { $error = "Please fill the spaces completely"; include ("contactus.html"); exit(); } ?> You are only checking the name though.. so the rest could be blank and you should filter the variables. Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218270 Share on other sites More sharing options...
BrotherBear Posted March 30, 2007 Author Share Posted March 30, 2007 the error that I need to fill all spaces and this error appears even if I fill the space here's the code of the error if ($Name==0) $error = "Please fill the spaces completely"; include ("contactus.html"); exit(); mysql_select_db("johncoda_downloa", $con); BB Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218273 Share on other sites More sharing options...
spfoonnewb Posted March 30, 2007 Share Posted March 30, 2007 Try what I replied in the edit. Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218274 Share on other sites More sharing options...
BrotherBear Posted March 30, 2007 Author Share Posted March 30, 2007 I know about the name never will be equal to 1 that is just something that is not included in the actual scripting thanks I'll try BB Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218277 Share on other sites More sharing options...
BrotherBear Posted March 30, 2007 Author Share Posted March 30, 2007 did not work!!! now appears 500 internal server error the thing is that I want to make sure all spaces are filled so I puuted the error code above so that when one space wasn't filled the error appears and works the things is that this error appears even if you fill everything and doesn't continiue to upload the information BB Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218282 Share on other sites More sharing options...
spfoonnewb Posted March 30, 2007 Share Posted March 30, 2007 I am now confused in how you coded your script. You are already submitting to processing.php and then if the name field is filled in.. you are trying to include it processing.php again ??? That explains your 500 server error. It will never happen, it won't ever exit. <form action='processing.php' method='post'> include ("processing.php"); What else does processing.php do? You need to fix your validation code. Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218287 Share on other sites More sharing options...
BrotherBear Posted March 30, 2007 Author Share Posted March 30, 2007 I have 2 pages for this form the contactus.html where the form is it just has the form and the send button the processing.php is the one that has ALL the PHP scripting processing.php sends and stores the data in the database BB Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218291 Share on other sites More sharing options...
BrotherBear Posted March 31, 2007 Author Share Posted March 31, 2007 it's hard for me to explain exactly what I want listen click this link where the form is http://bbanddisney.freeprohost.com/contactus.html fill the form and then fill everything but the Name space and you'll see what I'm talking about BB Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218475 Share on other sites More sharing options...
Trium918 Posted March 31, 2007 Share Posted March 31, 2007 Try putting curly braces to close your if statements. If that doesn't work try the code below. if(empty($Name)) { echo "Please fill the spaces completely"; include ("contactus.html"); exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218482 Share on other sites More sharing options...
neel_basu Posted March 31, 2007 Share Posted March 31, 2007 By the way how did you coloured the codes according to php. (although the colour is not Correct) Quote Link to comment https://forums.phpfreaks.com/topic/44954-another-php-form-problem/#findComment-218533 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.