Hi Guys could do with some help!! Im new and am having a little trouble finding the error, have looked on previous threads and have checked all the "}" <?php if(isset($_POST['Submit'])) { //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name']) && (empty($_POST['email']))) { header("Location:Messages.php?msg=3"); exit(); } if( empty($_POST['pw1']) && (empty($_POST['pw2']))) { header( "Location:Messages.php?msg=4" ); exit(); } $name=$_POST['name']; $email=$_POST['email']; $pw1=$_POST['pw1']; $pw2=$_POST['pw2']; if("$pw1" !== "$pw2" ) { header( "Location:Messages.php?msg=5" ); exit(); } $ip = $_SERVER['REMOTE_ADDR']; //connect to the db server , check if uname exist include('config.php'); $query=("Select * from user where uname='$name'"); $result= mysql_query($query); $num= mysql_num_rows($result); if ($num > 0) {//Username already exist header( "Location:Messages.php?msg=6" ); exit(); }else { //if username does not exist insert user details $query=( "INSERT INTO user (uname, pw,email,date_joined,ip,level) VALUES ('$name',password('$pw1'),'$email',NOW(),'$ip','Normal')"); if (@mysql_query ($query)) { header("location:login.php?reg=1"); exit; } } mysql_close(); } ?>
Try taking this part (lines 1-3): <?php if(isset($_POST['Submit'])) { //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name']) && (empty($_POST['email']))) PHP: and replacing it with this: <?php if(array_key_exists('Submit', $_POST)) { //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name']) && (empty($_POST['email']))) PHP: That should resolve your issue. -Bing
<?php if(array_key_exists('Submit', $_POST)) { //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name']) && (empty($_POST['email']))) { header("Location:Messages.php?msg=3"); exit(); } if( empty($_POST['pw1']) && (empty($_POST['pw2']))) { header( "Location:Messages.php?msg=4" ); exit(); } $name=$_POST['name']; $email=$_POST['email']; $pw1=$_POST['pw1']; $pw2=$_POST['pw2']; if("$pw1" !== "$pw2" ) { header( "Location:Messages.php?msg=5" ); exit(); } $ip = $_SERVER['REMOTE_ADDR']; //connect to the db server , check if uname exist include('config.php'); $query=("Select * from user where uname='$name'"); $result= mysql_query($query); $num= mysql_num_rows($result); if ($num > 0) {//Username already exist header( "Location:Messages.php?msg=6" ); exit(); }else { //if username does not exist insert user details $query=( "INSERT INTO user (uname, pw,email,date_joined,ip,level) VALUES ('$name',password('$pw1'),'$email',NOW(),'$ip','Normal')"); if (@mysql_query ($query)) { header("location:login.php?reg=1"); exit; } } mysql_close(); } ?> PHP: I have edited the code so that it now looks like the above. Now error message says Parse error: syntax error, unexpected '{' in /register.php on line 1 :S So now there is one too many "{"??
<?php session_start(); if(array_key_exists('reg', $_GET)) { $reg=$_GET['reg']; }else { $reg=""; } if($reg==1) { $msg1="<font color=\"#FF0000\"><b>Your details have been added, please login</b></font>"; } if($reg==2) { $msg1="<font color=\"#FF0000\"><b>You have been successfully logged out.</b></font>"; } if(array_key_exists('Submit', $_POST)) { if( empty($_POST['uname']) && (empty($_POST['upass']))) { header( "Location:Messages.php?msg=1" ); exit(); } //transfer to shorter var $n=$_POST['uname']; $p=$_POST['upass']; //connect to db include('config.php'); $query="select * from user where uname='$n' and pw='$p' "; $result=mysql_query($query); $num=mysql_num_rows($result); if($num>0 ) { //put in session vars $mytime=time(); $mytime=date("H:i:s A",$mytime); $_SESSION['time'] = $mytime; $_SESSION['status'] = 'logged'; $_SESSION['username'] = $n; //goto next page header("location:welcome.php"); exit(); }else { $_SESSION['status'] = 'not logged'; header( "Location:Messages.php?msg=2" ); exit(); } } ?> PHP: Another one with exactly the same error message. I have changed the coding to the example given above by byPasc95
[h=2]Can anyone help....[/h]My screen reads Parse error T_ENDIF in ..... on line 172...I think its in here <?php if ($this->countModules('user4') or $this->countModules('user5') or $this->countModules('user6') or $this->countModules('user7')) : ?> <div id="bottom"> <div id="bottommodules" class="spacer<?php echo $bottommods_width; ?>"> <?php if ($this->countModules('user4')) : ?> <div class="block"> <jdoc:include type="modules" name="user4" style="rounded" /> </div> <?php endif; ?> <?php if ($this->countModules('user5')) : ?> <div class="block"> <jdoc:include type="modules" name="user5" style="rounded" /> </div> <?php endif; ?> <?php if ($this->countModules('user6')) : ?> <div class="block"> <jdoc:include type="modules" name="user6" style="rounded" /> </div> <?php endif; ?> <?php if ($this->countModules('user7')) : ?> <div class="block"> <jdoc:include type="modules" name="user7" style="rounded" /> </div> <?php endif; ?> </div> </div> <?php endif; ?>
[h=2]Can anyone help....[/h]My screen reads Parse error T_ENDIF in ..... on line 172...I think its in here <?php if ($this->countModules('user4') or $this->countModules('user5') or $this->countModules('user6') or $this->countModules('user7')) : ?> <div id="bottom"> <div id="bottommodules" class="spacer<?php echo $bottommods_width; ?>"> <?php if ($this->countModules('user4')) : ?> <div class="block"> <jdoc:include type="modules" name="user4" style="rounded" /> </div> <?php endif; ?> <?php if ($this->countModules('user5')) : ?> <div class="block"> <jdoc:include type="modules" name="user5" style="rounded" /> </div> <?php endif; ?> <?php if ($this->countModules('user6')) : ?> <div class="block"> <jdoc:include type="modules" name="user6" style="rounded" /> </div> <?php endif; ?> <?php if ($this->countModules('user7')) : ?> <div class="block"> <jdoc:include type="modules" name="user7" style="rounded" /> </div> <?php endif; ?> </div> </div> <?php endif; ?>