legohead6 Posted April 2, 2006 Share Posted April 2, 2006 everything works...but the last 'if'.... it checks everything and if correct sends off the form to a database!(bolded) please help! also please only rewrite what i should put replacing the bold...(makes it less confusing)<html><head><title></title></head><body text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><p align="center"><font face="Aachen-Bold" size="6" color="#FF0000">SplatmenPaintball Club</font><p align="center"><font color="#FF0000" face="Comic Sans MS"><a href="http://">Home</a> <a href="../Pictures.htm">Pictures</a> <a href="members.php">Members</a> <a href="http://www.mattswebpage.com/mainforum/viewforum.php?f=1&sid=4ab3e05eef87dc57e23c7fdf72eb13ab">Forum</a> <a href="../Membership.php"> Player Info</a> <a href="../Chat_Room.htm">Chat room</a><a href="../schedule.htm"> Schedule</a> <a href="../Contact.htm"> Contact</a></font></p><p><?phpif(isset($_POST['submit'])){if(!empty($_POST['first'])){$first=$_POST['first'];}else{$name = NULL;echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";}if(!empty($_POST['last'])){$last=$_POST['last'];}else{$last = NULL;echo "<p><font color=\"yellow\">*Please enter your last Name!</font></p>";}if(!empty($_POST['gun'])){$gun=$_POST['gun'];}else{$gun = NULL;echo "<p><font color=\"yellow\">*Please enter what kind of gun you have!</font></p>";}if(!empty($_POST['age'])){$age=$_POST['age'];}else{$age = NULL;echo "<p><font color=\"yellow\">*Please enter how old you are!</font></p>";}if(!empty($_POST['saying'])){$saying=$_POST['saying'];}else{$saying = NULL;echo "<p><font color=\"yellow\">*Please enter a saying!</font></p>";}if(!empty($_POST['email'])){$email=$_POST['email'];}else{$email = NULL;echo "<p><font color=\"yellow\">*Please enter your Email Address!</font></p>";}if(!empty($_POST['phone'])){$phone=$_POST['phone'];}else{$phone = NULL;echo "<p><font color=\"yellow\">*Please enter your Phone Number!</font></p>";}if(!empty($_POST['user'])){$users=$_POST['user'];}else{$users = NULL;echo "<p><font color=\"yellow\">*Please enter a Username!</font></p>";}if(!empty($_POST['pass'])){$passs=$_POST['passs'];}else{$passs = NULL;echo "<p><font color=\"yellow\">*Please enter a Password!</font></p>";}[b]if ($first && $last && $gun && $age && $saying && $email && $phone && $users && $passs) {$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");mysql_select_db($db) or die ("Unable to select database!");$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}[/b]}?><form method="POST" name="membership" action="Membership.php"><p align="center">First name <input type="text" name="first" size="20">Last Name:<input type="text" name="last" size="24"><br><br>Phone#<input type="text" name="phone">(format= 000-0000)<p align="center">Gun type:<input type="text" name="gun" size="36"><br><br>Age:<input type="text" name="age" size="3"><br><br>Saying:<br><textarea rows="2" name="saying" cols="20"></textarea></p><p align="center">Current email address:<input type="text" name="email" size="36"></p><p align="center">Desired Username:<input type="text" name="user" size="20"></p><p align="center">Desired pass:<input type="password" name="pass" size="20"></p><p align="center"></p><p align="center"><input type="submit" value="Submit" name="submit"></p></form></html> Quote Link to comment Share on other sites More sharing options...
darkcarnival Posted April 2, 2006 Share Posted April 2, 2006 [code]if (($first) AND ($last) AND ($gun) AND ($age) AND ($saying) AND ($email) AND ($phone) AND ($users) AND ($passs)){$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");mysql_select_db($db) or die ("Unable to select database!");$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}[/code]try that ;) Quote Link to comment Share on other sites More sharing options...
legohead6 Posted April 2, 2006 Author Share Posted April 2, 2006 [!--quoteo(post=360782:date=Apr 1 2006, 09:25 PM:name=darkcarnival)--][div class=\'quotetop\']QUOTE(darkcarnival @ Apr 1 2006, 09:25 PM) [snapback]360782[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]if (($first) AND ($last) AND ($gun) AND ($age) AND ($saying) AND ($email) AND ($phone) AND ($users) AND ($passs)){$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");mysql_select_db($db) or die ("Unable to select database!");$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}[/code]try that ;)[/quote]no didnt work i tried replacing the connection stuff with an echo and it still didnt work so it much be something wrong with the if statement..(maybe something to do with the rest of the code?) Quote Link to comment Share on other sites More sharing options...
darkcarnival Posted April 2, 2006 Share Posted April 2, 2006 ok well i have another idea for ya.i did this for a install script i made.basically a variable that would be set to ture all the time.then check for that variable.heres an eamxple of what i mean.if($name !== ""){$name_r = true;}if ($age !== ""){$age_r = true;}then check for those variables like so:if (($name_r == true) and ($age_r == true)){//go further in script}give that a try. Quote Link to comment Share on other sites More sharing options...
legohead6 Posted April 2, 2006 Author Share Posted April 2, 2006 this comes up....line 97 is the if command...Parse error: parse error, unexpected '{' in /var/www/html/splatmenpaintball/memshiphandler.php on line 97when i remove the { stating where the if command starts it says unexpecting T_variable Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 2, 2006 Share Posted April 2, 2006 You can also try like this but add this afther trying the below code.[code]if ((!$first)||(!$last)||(!$gun)||(!$age)||(!$saying)||(!$email)||(!$phone)||(!$users)||(!$passs)) {}[/code]Try The code this way ok if the database gets the entrys then add the above code ok or leave as it is.Good luck.Always make a backup of your data before trying anythink.[code]<html><head><title></title></head><body text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><p align="center"><font face="Aachen-Bold" size="6" color="#FF0000">SplatmenPaintball Club</font><p align="center"><font color="#FF0000" face="Comic Sans MS"><a href="http://">Home</a><a href="../Pictures.htm">Pictures</a> <a href="members.php">Members</a> <a href="http://www.mattswebpage.com/mainforum/viewforum.php?f=1&sid=4ab3e05eef87dc57e23c7fdf72eb13ab">Forum</a><a href="../Membership.php">Player Info</a> <a href="../Chat_Room.htm">Chat room</a><a href="../schedule.htm"> Schedule</a> <a href="../Contact.htm"> Contact</a></font></p><p><?php$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");mysql_select_db($db) or die ("Unable to select database!");if(isset($_POST['submit'])){if(!empty($_POST['first'])){$first=$_POST['first'];}else{$name = NULL;echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";}if(!empty($_POST['last'])){$last=$_POST['last'];}else{$last = NULL;echo "<p><font color=\"yellow\">*Please enter your last Name!</font></p>";}if(!empty($_POST['gun'])){$gun=$_POST['gun'];}else{$gun = NULL;echo "<p><font color=\"yellow\">*Please enter what kind of gun you have!</font></p>";}if(!empty($_POST['age'])){$age=$_POST['age'];}else{$age = NULL;echo "<p><font color=\"yellow\">*Please enter how old you are!</font></p>";}if(!empty($_POST['saying'])){$saying=$_POST['saying'];}else{$saying = NULL;echo "<p><font color=\"yellow\">*Please enter a saying!</font></p>";}if(!empty($_POST['email'])){$email=$_POST['email'];}else{$email = NULL;echo "<p><font color=\"yellow\">*Please enter your Email Address!</font></p>";}if(!empty($_POST['phone'])){$phone=$_POST['phone'];}else{$phone = NULL;echo "<p><font color=\"yellow\">*Please enter your Phone Number!</font></p>";}if(!empty($_POST['user'])){$users=$_POST['user'];}else{$users = NULL;echo "<p><font color=\"yellow\">*Please enter a Username!</font></p>";}if(!empty($_POST['pass'])){$passs=$_POST['passs'];}else{$passs = NULL;echo "<p><font color=\"yellow\">*Please enter a Password!</font></p>";}$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}?><form method="POST" name="membership" action="Membership.php"><p align="center">First name <input type="text" name="first" size="20">Last Name:<input type="text" name="last" size="24"><br><br>Phone#<input type="text" name="phone">(format= 000-0000)<p align="center">Gun type:<input type="text" name="gun" size="36"><br><br>Age:<input type="text" name="age" size="3"><br><br>Saying:<br><textarea rows="2" name="saying" cols="20"></textarea></p><p align="center">Current email address:<input type="text" name="email" size="36"></p><p align="center">Desired Username:<input type="text" name="user" size="20"></p><p align="center">Desired pass:<input type="password" name="pass" size="20"></p><p align="center"></p><p align="center"><input type="submit" value="Submit" name="submit"></p></form></html>[/code] Quote Link to comment Share on other sites More sharing options...
legohead6 Posted April 2, 2006 Author Share Posted April 2, 2006 [!--quoteo(post=360912:date=Apr 2 2006, 12:06 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Apr 2 2006, 12:06 PM) [snapback]360912[/snapback][/div][div class=\'quotemain\'][!--quotec--]You can also try like this but add this afther trying the below code.[code]if ((!$first)||(!$last)||(!$gun)||(!$age)||(!$saying)||(!$email)||(!$phone)||(!$users)||(!$passs)) {}[/code]Try The code this way ok if the database gets the entrys then add the above code ok or leave as it is.Good luck.Always make a backup of your data before trying anythink.[code]<html><head><title></title></head><body text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><p align="center"><font face="Aachen-Bold" size="6" color="#FF0000">SplatmenPaintball Club</font><p align="center"><font color="#FF0000" face="Comic Sans MS"><a href="http://">Home</a><a href="../Pictures.htm">Pictures</a> <a href="members.php">Members</a> <a href="http://www.mattswebpage.com/mainforum/viewforum.php?f=1&sid=4ab3e05eef87dc57e23c7fdf72eb13ab">Forum</a><a href="../Membership.php">Player Info</a> <a href="../Chat_Room.htm">Chat room</a><a href="../schedule.htm"> Schedule</a> <a href="../Contact.htm"> Contact</a></font></p><p><?php$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");mysql_select_db($db) or die ("Unable to select database!");if(isset($_POST['submit'])){if(!empty($_POST['first'])){$first=$_POST['first'];}else{$name = NULL;echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";}if(!empty($_POST['last'])){$last=$_POST['last'];}else{$last = NULL;echo "<p><font color=\"yellow\">*Please enter your last Name!</font></p>";}if(!empty($_POST['gun'])){$gun=$_POST['gun'];}else{$gun = NULL;echo "<p><font color=\"yellow\">*Please enter what kind of gun you have!</font></p>";}if(!empty($_POST['age'])){$age=$_POST['age'];}else{$age = NULL;echo "<p><font color=\"yellow\">*Please enter how old you are!</font></p>";}if(!empty($_POST['saying'])){$saying=$_POST['saying'];}else{$saying = NULL;echo "<p><font color=\"yellow\">*Please enter a saying!</font></p>";}if(!empty($_POST['email'])){$email=$_POST['email'];}else{$email = NULL;echo "<p><font color=\"yellow\">*Please enter your Email Address!</font></p>";}if(!empty($_POST['phone'])){$phone=$_POST['phone'];}else{$phone = NULL;echo "<p><font color=\"yellow\">*Please enter your Phone Number!</font></p>";}if(!empty($_POST['user'])){$users=$_POST['user'];}else{$users = NULL;echo "<p><font color=\"yellow\">*Please enter a Username!</font></p>";}if(!empty($_POST['pass'])){$passs=$_POST['passs'];}else{$passs = NULL;echo "<p><font color=\"yellow\">*Please enter a Password!</font></p>";}$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}?><form method="POST" name="membership" action="Membership.php"><p align="center">First name <input type="text" name="first" size="20">Last Name:<input type="text" name="last" size="24"><br><br>Phone#<input type="text" name="phone">(format= 000-0000)<p align="center">Gun type:<input type="text" name="gun" size="36"><br><br>Age:<input type="text" name="age" size="3"><br><br>Saying:<br><textarea rows="2" name="saying" cols="20"></textarea></p><p align="center">Current email address:<input type="text" name="email" size="36"></p><p align="center">Desired Username:<input type="text" name="user" size="20"></p><p align="center">Desired pass:<input type="password" name="pass" size="20"></p><p align="center"></p><p align="center"><input type="submit" value="Submit" name="submit"></p></form></html>[/code][/quote]Thankyou know the form is acculy sent to the dtabase(sumthing musta been screwed up before) but even after adding the if statment it still sends if fields are left blank..... Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 2, 2006 Share Posted April 2, 2006 Try it with a die; or exit;[code]if(isset($submit)) {if(!empty($_POST['first'])){$first=$_POST['first'];}else{$name = NULL;echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";die;}}[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 2, 2006 Share Posted April 2, 2006 I think this is correct not sure.[code]$first=$_POST['first'];// set before postingif(isset($submit)) {if(!empty(['first'])) {echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";}}[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 2, 2006 Share Posted April 2, 2006 I got it to work this way try it.[code]<?$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");$first=$_POST['first'];// set before postingif($submit) {if(empty($first)) {echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";}$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}?><form method="post" action=""><input type="text" name="$first"><input type="submit" name="submit"></form>[/code] Quote Link to comment Share on other sites More sharing options...
legohead6 Posted April 2, 2006 Author Share Posted April 2, 2006 I got it using a book i just bought!!! i used an array! everything worked perfectly!heres the finnal code![code]<html><head><title></title></head><body text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><p align="center"><font face="Aachen-Bold" size="6" color="#FF0000">SplatmenPaintball Club</font><p align="center"><font color="#FF0000" face="Comic Sans MS"><a href="http://">Home</a><a href="../Pictures.htm">Pictures</a> <a href="members.php">Members</a> <a href="http://www.mattswebpage.com/mainforum/viewforum.php?f=1&sid=4ab3e05eef87dc57e23c7fdf72eb13ab">Forum</a><a href="../Membership.php">Player Info</a> <a href="../Chat_Room.htm">Chat room</a><a href="../schedule.htm"> Schedule</a> <a href="../Contact.htm"> Contact</a></font></p><p><?phpif(isset($_POST['submit'])){$errors = array(); if(empty($_POST['first'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your first Name!</font></p>'; }else{ $first=$_POST['first']; } if(empty($_POST['last'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your last Name!</font></p>'; }else{ $last=$_POST['last']; } if(empty($_POST['gun'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your gun type!</font></p>'; }else{ $gun=$_POST['gun']; } if(empty($_POST['age'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your age!</font></p>'; }else{ $age=$_POST['age']; } if(empty($_POST['saying'])){ $errors[] = '<p><font color=\"yellow\">*Please enter a saying!</font></p>'; }else{ $saying=$_POST['saying']; } if(empty($_POST['email'])){ $errors[] = '<p><font color=\"yellow\">*Please enter a email!</font></p>'; }else{ $email=$_POST['email']; } if(empty($_POST['phone'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your Phone number!</font></p>'; }else{ $phone=$_POST['phone']; } if(empty($_POST['user'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your Username!</font></p>'; }else{ $users=$_POST['user']; } if(empty($_POST['pass'])){ $errors[] = '<p><font color=\"yellow\">*Please enter your Password!</font></p>'; }else{ $passs=$_POST['pass']; }if (empty($errors)) {$host = "localhost";$user = "--";$pass = "--";$db = "mattswebpage_com_-_web";$connection = mysql_connect($host,$user,$pass) or die ("Unable toconnect!");mysql_select_db($db) or die ("Unable to select database!");$query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";mysql_query($query);}else{foreach ($errors as $key){echo "$key";}}}?><form method="POST" name="membership" action="Membership.php"><p align="center">First name <input type="text" name="first" size="20">Last Name:<input type="text" name="last" size="24"><br><br>Phone#<input type="text" name="phone">(format= 000-0000)<p align="center">Gun type:<input type="text" name="gun" size="36"><br><br>Age:<input type="text" name="age" size="3"><br><br>Saying:<br><textarea rows="2" name="saying" cols="20"></textarea></p><p align="center">Current email address:<input type="text" name="email" size="36"></p><p align="center">Desired Username:<input type="text" name="user" size="20"></p><p align="center">Desired pass:<input type="password" name="pass" size="20"></p><p align="center"></p><p align="center"><input type="submit" value="Submit" name="submit"></p></form></html>[/code]thankyou to everyone who 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.