Jump to content

Recommended Posts

Hi,

 

Im using a php image varification script on my site. The problem is that when a user enters an incorrect code it just takes them to a blank page. I want it to stay on my page and display an error, all the code is there i just cant get it to work.

 

Here is my code:

 

<?php

session_start();
include("connect.php");
include("header.php");

if( isset($_POST['submit'])) {
   if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
      if(isset($submit))
{	
	$query = "select * from user where username = '$username' and status = 'ACTIVE'";
	$result = mysql_query($query);
	$num = mysql_num_rows($result);
	if($num < 1)
	{
		$date_of_birth = $birthday_yr."-".$birthday_mon."-".$birthday_day;
		$signup = date("Y-m-d");	
		if(isset($newsletter))
			$newsletter = "YES";
		else
			$newsletter = 'NO';	

$validation = md5(rand(1, 1000));
		$insert_query = "insert into user (email,username,password,country,gender,date_of_birth,signup,newsletter,terms, activated,validation_code) 
		values('$email','$username','$password','$country','$gender','$date_of_birth','$signup','$newsletter', '$terms', '0',  '$validation')";
		$insert_result = mysql_query($insert_query);
		if($refUser != '')
		{		
			$update_friends = "update friends set status = 'CONFIRM',friend_id ='$newUserInsertId' where user_reference_id = '$refUser' and status = 'ACITVE'";
			$update_result = mysql_query($update_friends);
		}	
		if(isset($insert_result))
		{
		$message = '<html>
<head>
<title>Welcome To lll.com</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
    <tr valign="top">
      <td><div>
          <h2>Thank You for Signing Up!</h2>
          <p>You\'ve taken the next step in becoming part of the lll community. Now that you\'re a member, you can rate music, but to leave comments or upload your own music to the site, you\'ll first need to confirm your email by <a <a href="http://www.lll.com/validate.php?user='. $username .'&code='. $validation.'" target="_blank">Clicking Here</a>, or pasting the following link into your browser:<br />
            <br />
            <a href="http://www.lll.com/validate.php?user='. $username .'&code='. $validation.'" target="_blank">http://www.lll.com/validate.php?user='. $username .'&code='. $validation.'</a> <br />
            <br />
            Please take a look at our <a href="http://www.lll.com/terms" target="_blank">Terms of Use</a> and <a href="http://www.lll.com/copyright.php" target="_blank">Copyright Tips</a> before uploading so that you understand what\'s allowed on the site.</p>
          <p>To get you started, here are some of the things you can do with lll:</p>
          <ul>
            <li><a href="http://www.lll.com/upload.php" target="_blank">Upload</a> and share your music worldwide</li>
            <li><a href="http://www.lll.com/audios/browse.php" target="_blank">Browse</a> millions of original and unsigned tracks</li>
            <li>Find, join and create groups to connect with people who have similar interests</li>
            <li>Customize your experience with playlists and subscriptions</li>
            <li>Integrate lll with your website using audio embeds or APIs</li>
          </ul>
          <p>There\'s a lot more to explore, and more features are always in the works. Thanks for signing up, and we hope you enjoy the site!</p>
          <p>The <a href="http://www.lll.com/contact.php" target="_blank">lll Team</a></p>
        </div></td>
    </tr>
  </tbody>
</table>
</body>
</html>
';
            $subject = "Welcome to lll.com!";
            $email = "$email";
		$headers .= 'From: lll.com <[email protected]>'. "\r\n";
		$headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            mail($email,$subject,$message,$headers);
		header("Location:login.php");

	}else{
		$ERROR = "Username Already Present.";
	}	
   } else {
  echo ('Sorry, you have provided an invalid security code');
   }
   }
   }
   }else{
?>

Link to comment
https://forums.phpfreaks.com/topic/41059-error-help/
Share on other sites

At the end of your script you have your else in wrong place for displaying the message 'Sorry, you have provided an invalid security code''

 

The bottom of your code should be like this:

}else{
		$ERROR = "Username Already Present.";
	}	
   }
   }
   } else {
  echo ('Sorry, you have provided an invalid security code');
   }
   }else{

Link to comment
https://forums.phpfreaks.com/topic/41059-error-help/#findComment-199060
Share on other sites

That works fine untilll i do this:

 

}else{
		$ERROR = "Username Already Present.";
	}	
   }
   }
   } else {
  $MSG = "Sorry, you have provided an invalid security code.";
   }
   }else{

 

Then i echo the $MSG with:

 

<?php } if(isset($MSG))  { ?>
                          <tr>
                            <td align="center"><font color="#FF0000">
                              <?php echo $MSG;	?>
                              </font></td>

 

It just refuses to show, im wanting the message to apear in the body of my page not just on a blank screen.

Link to comment
https://forums.phpfreaks.com/topic/41059-error-help/#findComment-199090
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.