mikebyrne Posted March 7, 2008 Share Posted March 7, 2008 I've adjusted my form to one page with the validation taking place on this page. I'm trying to get an error to appear if the user DOESN'T enter a name and presses the insert button. At present the error appears either way <?php if($_POST["action"] == "signup"){ $valid=1; echo $_POST["name"]; if (($name == "")) { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>e-commerce admin page sample |item</title> <link href="/Admin_files/admin.css" rel="stylesheet" type="text/css" /> <script type="text/JavaScript" src="file:///C|/Users/Mike/Documents/Admin_files/wrapper.js"></script> </head> <body> <div id="Box"> <div id="logoBox"><a href="http://www.btrax.com/" target="_blank"><img src="file:///C|/Users/Mike/Documents/Admin_files/logo.gif" width="51" height="125" border="0" /></a></div> <div id="contentBox"> <!-- logo start --> <div id="container"> <div class="padTop28"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- logo finish --> <!-- menu start --> <div id="container"> <div id="menu1"> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="file:///C|/Users/Mike/Documents/admin_files/new.php" class="black"> Order</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="file:///C|/Users/Mike/Documents/admin_files/sales.php" class="black"> Sales</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_on"><a href="file:///C|/Users/Mike/Documents/admin_files/list.php" class="black"> Edit item</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="file:///C|/Users/Mike/Documents/shipping/current.php" class="black"> Postage fee</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_on"><!-- --></div> <div id="menu_text_off"><a href="file:///C|/Users/Mike/Documents/shipping/current.php" class="black_on"> Add User</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="file:///C|/Users/Mike/Documents/shipping/current.php" class="black"> Add Product</a></div> <div id="menu_space1"><!-- --></div> </div> <div class="clr"><!-- --></div> <div class="clr"> <!-- --> </div> <div class="padTop5"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div id="dotted"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div class="padTop5"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div id="menu2"> <div id="menu_hide"> <!-- --> </div> <div id="menu_text_off"> </div> <div id="menu_space1"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop38"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- menu finish --> <!-- top start --> <div id="container"> <div id="line"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div id="containerBg1"> <div class="padTop15"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div id="titleText">REGISTER EMPLOYEE</div> <div class="clr"> <!-- --> </div> <div class="padTop15"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- top finish --> <!-- data title start --> <div id="containerBg2"> <div class="padTop2"> <!-- --> </div> <div class="clr"> <!-- --> </div> <form name="form" method="post" action="adminreg.php"> <table align="center" width="546"> <tr valign="baseline"> <td nowrap align="right" width="95">Name:</td> <td nowrap align="right"> <input name="name" type="text" size="32" style="font-size: 8pt; $style_name; float:left" value="<?php echo $name; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_name; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address:</td> <td nowrap align="right"> <input name="address" size="32" style="font-size: 8pt; $style_address; float:left" value="<?php echo $address; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address1:</td> <td nowrap align="right"> <input name="address1" size="32" style="font-size: 8pt; $style_address1; float:left" value="<?php echo $address1; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address1; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address2:</td> <td nowrap align="right"> <input name="address2" size="32" style="font-size: 8pt; $style_address2; float:left" value="<?php echo $address2 ;?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address2; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address3:</td> <td nowrap align="right"> <input name="address3" size="32" style="font-size: 8pt; $style_address3; float:left" value="<?php echo $address3; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address3; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address4:</td> <td nowrap align="right"> <input name="address4" size="32" style="font-size: 8pt; $style_address4; float:left" value="<?php $address4; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address4;?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">County:</td> <td nowrap align="right"> <input name="county" size="32" style="font-size: 8pt; $style_county; float:left" value="<?php echo $county; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_county ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Zip:</td> <td nowrap align="right"> <input name="zip" size="32" style="font-size: 8pt; $style_zip; float:left" value="<?php echo $zip; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_zip;?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Telephone:</td> <td nowrap align="right"> <input name="telephone" size="32" style="font-size: 8pt; $style_telephone; float:left" value="<?php $telephone; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><? echo $error_telephone; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Email:</td> <td nowrap align="right"> <input name="email" size="32" style="font-size: 8pt; $style_email; float:left" value="<?php $email;?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_email;?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Username:</td> <td nowrap align="right"> <input name="username" size="32" style="font-size: 8pt; $style_username; float:left"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_username; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Password:</td> <td nowrap align="right"> <input name="password" size="32" style="font-size: 8pt; $style_password; float:left"type="password"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_password; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95"> </td> <td nowrap align="right"> <input type=hidden name=action value="signup"> <input type="submit" value="Insert record" style="float: left"> </td> <td width="269"> </td> </tr> </table> </form> </div> <!-- btm start --> <div id="containerBg1"> <div class="padTop15"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <div id="container"> <div id="line"><!-- --></div> </div> <!-- btm finish --> </div> </div> </body> </html> The echo $_POST["name"]; post the "name" on the top of the screen so not too sure why the validation isnt taking place Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 7, 2008 Share Posted March 7, 2008 It should be: if ($_POST['name'] == "") { Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 That fixed it! THANKS Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 Sorry. Im now having a problem with my 2nd validation step if (($_POST('address') == "") or (strlen('address')<2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } Getting the error Fatal error: Function name must be a string in C:\xampp\htdocs\Admin_files\adminreg.php on line 13 I've typed in the word Ashville into address Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 The validation code is as follows but it has a problem with (strlen('address')<2)), have a phrased this correctly?? <?php if($_POST["action"] == "signup"){ $valid=1; echo $_POST["name"]; if (($name == "")) { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } if (($_POST('address') == "") or (strlen('address')<2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } ?> Quote Link to comment Share on other sites More sharing options...
eddierosenthal Posted March 7, 2008 Share Posted March 7, 2008 (strlen('address')<2)) is not a variable, and you want to test against a var right? i thought '$var' was the correct syntax for discovering the var. so you might try strlen('$address') to get that... also your OR statement stands alone, is that what you want. try ( a==b OR c==d ) by using correct placement and number of parens. I think you have ( a==b) or (c==d) without enclosing the or in the whole logic. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 I've tried if (($_POST('address') == "") or (strlen($address)<2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; But still getting the error Fatal error: Function name must be a string in C:\xampp\htdocs\Admin_files\adminreg.php on line 13 line 13 = if (($_POST('address') == "") or (strlen($address)<2)) { Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 7, 2008 Share Posted March 7, 2008 It should be if (($_POST['address'] == "") || (strlen($_POST['address']) < 2)) { Quote Link to comment Share on other sites More sharing options...
chronister Posted March 7, 2008 Share Posted March 7, 2008 Whenever your dealing with form variables, you have to use them as $_POST['fieldname'] or $newVar = $_POST['fieldname']; Seems you have tried a few times to use the data in the wrong way. I find it a lot easier to set friendly variable names for the fields that were submitted right from the get go. e.g <?php if(isset($_POST['submit_button'])) { $name = $_POST['name']; $email = $_POST['email_address']; $message = $_POST['message']; /* down here you can now use the friendly names for the vars..... echo $name .' '. $email .' '. $message; */ } ?> Nate Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 That fixed the first 2 parts of validation but the code doesnt work for lines address1 to address4 but address works fine! <?php if($_POST["action"] == "signup"){ $valid=1; if ($_POST['name'] == "") { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } if (($_POST['address'] == "") || (strlen($_POST['address']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address1'] == "") || (strlen($_POST['address1']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address2'] == "") || (strlen($_POST['address2']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address3'] == "") || (strlen($_POST['address3']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address4'] == "") || (strlen($_POST['address4']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } } ?> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 Getting the error Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\Admin_files\adminreg.php on line 43 line 43 is: if (($_POST['county']=="") or (strlen($_POST['county']<2)) { <?php if($_POST["action"] == "signup"){ $valid=1; if ($_POST['name']=="") { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } if (($_POST['address']=="") || (strlen($_POST['address']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address1']=="") || (strlen($_POST['address1']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address2']=="") || (strlen($_POST['address2']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address3']=="") || (strlen($_POST['address3']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address4']=="") || (strlen($_POST['address4']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['county']=="") or (strlen($_POST['county']<2)) { $valid=0; $style_county = "background-color:#FF5959"; $error_county = "The County field is blank?<br>"; } } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 7, 2008 Share Posted March 7, 2008 <?php if ($_POST["action"] == "signup") { $valid=1; if ($_POST['name']=="") { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } if (($_POST['address']=="") || (strlen($_POST['address']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address1']=="") || (strlen($_POST['address1']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address2']=="") || (strlen($_POST['address2']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address3']=="") || (strlen($_POST['address3']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address4']=="") || (strlen($_POST['address4']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['county']=="") || (strlen($_POST['county'])<2)) { $valid=0; $style_county = "background-color:#FF5959"; $error_county = "The County field is blank?<br>"; } } ?> You had to change that line to: if (($_POST['county']=="") || (strlen($_POST['county'])<2)) { Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 7, 2008 Author Share Posted March 7, 2008 Sorry, I saw and adjusted that. At present I cant get address1, address2, address3, address4 to validate. Cant see a reason why it doesnt?? <?php if($_POST["action"] == "signup"){ $valid=1; if ($_POST['name']=="") { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } if (($_POST['address']=="") || (strlen($_POST['address']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address1']=="") || (strlen($_POST['address1']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address2']=="") || (strlen($_POST['address2']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address3']=="") || (strlen($_POST['address3']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['address4']=="") || (strlen($_POST['address4']) < 2)) { $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if (($_POST['county']=="") || (strlen($_POST['county'])<2)) { $valid=0; $style_county = "background-color:#FF5959"; $error_county = "The County field is blank?<br>"; } } ?> the form looks like this <form name="form" method="post" action="adminreg.php"> <table align="center" width="546"> <tr valign="baseline"> <td nowrap align="right" width="95">Name:</td> <td nowrap align="right"> <input name="name" type="text" size="32" style="font-size: 8pt; $style_name; float:left" value="<?php echo $name; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_name; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address:</td> <td nowrap align="right"> <input name="address" type="text" size="32" style="font-size: 8pt; $style_address; float:left" value="<?php echo $address; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address1:</td> <td nowrap align="right"> <input name="address1" type="text" size="32" style="font-size: 8pt; $style_address1; float:left" value="<?php echo $address1; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address1; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address2:</td> <td nowrap align="right"> <input name="address2" type="text" size="32" style="font-size: 8pt; $style_address2; float:left" value="<?php echo $address2 ;?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address2; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address3:</td> <td nowrap align="right"> <input name="address3" type="text" size="32" style="font-size: 8pt; $style_address3; float:left" value="<?php echo $address3; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address3; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Address4:</td> <td nowrap align="right"> <input name="address4" type="text" size="32" style="font-size: 8pt; $style_address4; float:left" value="<?php $address4; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_address4;?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">County:</td> <td nowrap align="right"> <input name="county" size="32" style="font-size: 8pt; $style_county; float:left" value="<?php echo $county; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_county ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Zip:</td> <td nowrap align="right"> <input name="zip" size="32" style="font-size: 8pt; $style_zip; float:left" value="<?php echo $zip; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_zip;?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Telephone:</td> <td nowrap align="right"> <input name="telephone" size="32" style="font-size: 8pt; $style_telephone; float:left" value="<?php $telephone; ?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><? echo $error_telephone; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Email:</td> <td nowrap align="right"> <input name="email" size="32" style="font-size: 8pt; $style_email; float:left" value="<?php $email;?>"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_email;?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Username:</td> <td nowrap align="right"> <input name="username" size="32" style="font-size: 8pt; $style_username; float:left"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_username; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95">Password:</td> <td nowrap align="right"> <input name="password" size="32" style="font-size: 8pt; $style_password; float:left"type="password"></td> <td width="269"><font color="#FF0000" style="font-size: 8pt"><?php echo $error_password; ?></font></td> </tr> <tr valign="baseline"> <td nowrap align="right" width="95"> </td> <td nowrap align="right"> <input type=hidden name=action value="signup"> <input type="submit" value="Insert record" style="float: left"> </td> <td width="269"> </td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 8, 2008 Share Posted March 8, 2008 Hmm...I don't see why it wouldn't. So your saying an error appears even if they aren't blank and they have more than two characters? Quote Link to comment Share on other sites More sharing options...
eddierosenthal Posted March 8, 2008 Share Posted March 8, 2008 I don't see how you got away with $style vars inside the html. if it were a javascript var it wouldn't need a $. and if it were a php var then it would be enclosed inside php tags wouldn't it? I guess i have a lot to learn there... why not take out the styling altogether and put it exterior to the script, and wrap the input fields inside id's or classes under control of the css file, and remove some of the baggage the file has, and possibly help you pin down the error? If you need to change style on the fly you can use javascript to do that part. hth Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 8, 2008 Author Share Posted March 8, 2008 I cant see why it doesnt work either!! I leave evey field blank and press the button but only get validation on 3 fields. (Name, address, county) address1, address2, address3 and address4 doesnt give an error report Quote Link to comment Share on other sites More sharing options...
chronister Posted March 8, 2008 Share Posted March 8, 2008 value="<?php $address4; ?>"> should be value="<?php echo $address4; ?>"> The second part lies with how your naming the error messages... I am not going to tell you, I want to teach you. Look at your error codes where you define them and then look at them and compare what you use to call them. My 1 biggest piece of advice to troubleshooting is ECHO ECHO ECHO ECHO..... To find the problems I grabbed your code and echo'd stuff out to see where it was failing. I should have noticed the problem right away, but your coding is a tad difficult to read. Your depending on Just In Time variables, meaning you are able to get away with letting the server turn $_POST['name'] into $name, not a good practice. If you move servers, or if they are turned off, which they should be then your code fails hard. To make your coding more readable try it like this. <?php $address1 = $_POST['address1']; if ($address1 == "" || strlen($address1) < 2) { echo 'got no address1<br>'//added by me to denote failure in this statement $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } ?> Hope this helps. Nate Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 8, 2008 Author Share Posted March 8, 2008 Ok, I've changed the opening php to <?php $name = $_POST['name']; $address = $_POST['address']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $address3 = $_POST['address3']; $address4 = $_POST['address4']; if($_POST["action"] == "signup"){ $valid=1; if ($_POST['name']=="") { echo 'got no name<br>' $valid=0; $style_name = "background-color:#FF5959"; $error_name = "Your name seems to be mising?<br>"; } if ($address == "" || strlen($address) < 2) { echo 'got no address1<br>'//added by me to denote failure in this statement $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if ($address1 == "" || strlen($address1) < 2) { echo 'got no address1<br>'//added by me to denote failure in this statement $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if ($address2 == "" || strlen($address2) < 2) { echo 'got no address2<br>'//added by me to denote failure in this statement $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if ($address3 == "" || strlen($address3) < 2) { echo 'got no address3<br>'//added by me to denote failure in this statement $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } if ($address4 == "" || strlen($address4) < 2) { echo 'got no address4<br>'//added by me to denote failure in this statement $valid=0; $style_address = "background-color:#FF5959"; $error_address = "There is a problem with the address field?<br>"; } ?> But im getting the error Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\Admin_files\adminreg.php on line 16 line 16 is: $valid=0; (on the the first validation part) Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 8, 2008 Share Posted March 8, 2008 You need to put a semi-colon after this line: echo 'got no name<br>' Quote Link to comment Share on other sites More sharing options...
chronister Posted March 8, 2008 Share Posted March 8, 2008 Ok, another hint.... <?php echo $error_address1; ?> <?php echo $error_address2; ?> take a look at those and find where you define them. Nate Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 9, 2008 Author Share Posted March 9, 2008 Thats great. Got it working. just have a small problem with the code checking if the usernamr already exists in the database but I'll start a new thread later on today. Thanks for all your help!! Quote Link to comment 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.