talor123 Posted March 31, 2008 Share Posted March 31, 2008 hey, im new to this site and php.. everytime i enter this code $new_user = $_POST["user"]; $new_password = $_POST["password"]; $new_password_confirm = $_POST["password_confirm"]; $new_first_name = $_POST["first_name"]; $new_sex = $_POST["sex"]; $new_email = $_POST["email"]; if (empty ($_POST['$new_user'])){ header("Location: login.php?message=Enter+a+Username."); exit; } (thats the part with errors) it tells me i have the "if" statement wrong.. ive also tryed if($new_user == 0)header("Location: login.php?message=Enter+a+Username."); exit; } ..ive tryed lots n they all come up with errors, please tell me how to fix it.. and btw this script just meants to make it so when your signing up on the form you cant leave spaces blank.. thank you Link to comment https://forums.phpfreaks.com/topic/98766-php-if-statement-help/ Share on other sites More sharing options...
Bladescope Posted March 31, 2008 Share Posted March 31, 2008 <?php // ... if($new_user == 0)header("Location: login.php?message=Enter+a+Username."); exit; } // ... ?> You haven't included the opening bracket for this IF statement. It should be: <?php // ... if($new_user == 0) { header("Location: login.php?message=Enter+a+Username."); exit; } // ... ?> Link to comment https://forums.phpfreaks.com/topic/98766-php-if-statement-help/#findComment-505419 Share on other sites More sharing options...
getshahidonline Posted March 31, 2008 Share Posted March 31, 2008 if (empty($new_user)){ header("Location: login.php?message=Enter+a+Username."); exit; } Link to comment https://forums.phpfreaks.com/topic/98766-php-if-statement-help/#findComment-505422 Share on other sites More sharing options...
talor123 Posted March 31, 2008 Author Share Posted March 31, 2008 hey i tryed what you put down.. it comes up saying Parse error: "parse error, unexpected T_IF" nany ideas what else to do? Link to comment https://forums.phpfreaks.com/topic/98766-php-if-statement-help/#findComment-505431 Share on other sites More sharing options...
getshahidonline Posted March 31, 2008 Share Posted March 31, 2008 just copy and paste and save as login.php <?php if(isset($_POST['submit'])) { $new_user = $_POST["user"]; //$new_password = $_POST["password"]; //$new_password_confirm = $_POST["password_confirm"]; //$new_first_name = $_POST["first_name"]; //$new_sex = $_POST["sex"]; //$new_email = $_POST["email"]; if (empty ($new_user)){ header("Location: one.php?message=Enter+a+Username."); exit; } } if(isset($_GET['message'])) { echo "$_GET[message]"; } echo " <form action='one.php' method='post'> <input type='text' name='user' /> <input type='submit' name='submit' value='Submit' /> </form> "; ?> Link to comment https://forums.phpfreaks.com/topic/98766-php-if-statement-help/#findComment-505440 Share on other sites More sharing options...
talor123 Posted March 31, 2008 Author Share Posted March 31, 2008 ..that would cut lots of stuff out(my full code for the login has lots more to it).. is there a way i can use a javascript function in a php script?? EG: <? javascript:check_all(''); // php stuff goes here >? or a code to put at then end of a javscript function that runs a php script??.. because i just made a javascript up that checks if the fields are empty, thats why it would be good if i could run the javascript function then if everythings filled out it would run the php script.. or something along those lines.. thanx Link to comment https://forums.phpfreaks.com/topic/98766-php-if-statement-help/#findComment-505443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.