Hi guys hope your all well, im having a problem with a register page on my website, Dreamweaver is saying there are no syntax errors, but when the information gets submitted, the check page isnt doing anything :(

This is the code i have:

<?php
session_start();
include_once"includes/dbconnect.php";

if ($_POST['Submit']){
	
	$user = $_POST['user'];
	$pass = $_POST['pass'];
	$email = $_POST['email1'];
	$emailc = $_POST['email2'];
	$month = strip_tags($_POST['month']);
	$day = strip_tags($_POST['day']);
	$year= strip_tags($_POST['year']);
	$country = strip_tags($_POST['country']);
	$today = gmdate('Y-m-d h:i:s');
	
	$user = stripslashes($user);
	$pass = stripslashes($pass);
	$email = stripslashes($email);
	$email1 = stripslashes($email1);
	
	if((!$user) || (!$email) || (!$pass) || (!$email1) || (!$month) || (!$day) || (!$year) || (!$country))	{
		die("Not every field was filled, go back and try again");
			}else{
	if ($email != $email1){
		die("E-Mail addresses didnt match");
			}elseif ($email == $email1){
	if (ereg('[^A-Za-z0-9]', $user)) {  
		die("Your username can only contain letters and numbers");
			}elseif (!ereg('[^A-Za-z0-9]', $user)) {
	if (strlen($user) <= 3 || strlen($user) >= 20){
	die("Username must be over 5 and under 30");
			}elseif (strlen($user) > 5 || strlen($user) < 30){
	if (strlen($pass) <= 5 || strlen($pass) >= 25) {
		die("Password must be over 5 and under 25");
			}elseif (strlen($pass) > 5 || strlen($pass) < 25) {
				
	$echeck = mysql_query("SELECT email FROM users WHERE email='$email'");
	$ucheck = mysql_query("SELECT username FROM users WHERE username='$user'");
	$echeck1 = mysql_num_rows($echeck);
	$ucheck1 = mysql_num_rows($ucheck);
	if(($echeck1 > 0) || ($ucheck1 > 0)){
       if($echeck1 > 0){
       	die("Your email address has already been used");
        unset($email);
    }
    if($ucheck1 > 0){
        die("Your desired username is already in use");
        unset($user);
    }
	}else{
		
  require_once('recaptchalib.php');
  $privatekey = "6LdEqb8SAAAAAPpRBQdASJOswREPbwMbXn-H0yNU";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die("The reCAPTCHA wasn't entered correctly. Go back and try it again."); 
           } else {
			   
    	if ($year != '' && $month != '' && $day != '') {
  	  	$date = $year.'-'.$month.'-'.$day;	

	$ip = $_SERVER['REMOTE_ADDR'];
	$ver = rand(111111111,999999999);
	
	mysql_query("INSERT INTO users (`id` , `username` , `password` , `email` , `dob` , `country` , `signupdate` , `ip` , `verifictation` , `verified`)
	VALUES('' , '$user' , $pass' , '$email' , '$date' , '$country' , '$today' , '$ip' , '$ver' , 'No' ,)");
  
  
  	$subject = "Thank you for registering with The Music Network";
    $message = "$user,
    Hello $user , Almost done, just need to verify your account, here is info on how to do so.

  First off, point your browser to: musicnetwork.razor-sharpdesigns.co.uk/verify.php
  
  and enter this code: $ver 
  
  And thats all, after you can user the service fully


    Login Information:
    Username: $user
    Password: $pass

    Thanks
    The Music Network Staff.

    This is an automated response, please do not reply!";

    mail($email, $subject, $message,
        "From: The Music Network<tmn@razor-sharpdesigns.co.uk>");
   $message= 'Account created, check email. ';
} }}}}}}}}
  ?>

Anyone got any protips?

Recommended Answers

All 7 Replies

Could be an error with your HTML form, something being mispelled so it doesn't actually POST the data "Submit".

Try adding in debug echos in at certain points to see how far the PHP gets before stopping - if it gets anywhere at all.

For example:

<?php
session_start();
include_once"includes/dbconnect.php";
echo('Checking the form has been submitted...');
if ($_POST['Submit']){
echo('Form has been submitted');
echo('etc, etc');
	
	$user = $_POST['user'];
	$pass = $_POST['pass'];
	$email = $_POST['email1'];
	$emailc = $_POST['email2'];
	$month = strip_tags($_POST['month']);
	$day = strip_tags($_POST['day']);
	$year= strip_tags($_POST['year']);
	$country = strip_tags($_POST['country']);
	$today = gmdate('Y-m-d h:i:s');
	
	$user = stripslashes($user);
	$pass = stripslashes($pass);
	$email = stripslashes($email);
	$email1 = stripslashes($email1);
	
	if((!$user) || (!$email) || (!$pass) || (!$email1) || (!$month) || (!$day) || (!$year) || (!$country))	{
		die("Not every field was filled, go back and try again");
			}else{
	if ($email != $email1){
		die("E-Mail addresses didnt match");
			}elseif ($email == $email1){
	if (ereg('[^A-Za-z0-9]', $user)) {  
		die("Your username can only contain letters and numbers");
			}elseif (!ereg('[^A-Za-z0-9]', $user)) {
	if (strlen($user) <= 3 || strlen($user) >= 20){
	die("Username must be over 5 and under 30");
			}elseif (strlen($user) > 5 || strlen($user) < 30){
	if (strlen($pass) <= 5 || strlen($pass) >= 25) {
		die("Password must be over 5 and under 25");
			}elseif (strlen($pass) > 5 || strlen($pass) < 25) {
				
	$echeck = mysql_query("SELECT email FROM users WHERE email='$email'");
	$ucheck = mysql_query("SELECT username FROM users WHERE username='$user'");
	$echeck1 = mysql_num_rows($echeck);
	$ucheck1 = mysql_num_rows($ucheck);
	if(($echeck1 > 0) || ($ucheck1 > 0)){
       if($echeck1 > 0){
       	die("Your email address has already been used");
        unset($email);
    }
    if($ucheck1 > 0){
        die("Your desired username is already in use");
        unset($user);
    }
	}else{
		
  require_once('recaptchalib.php');
  $privatekey = "6LdEqb8SAAAAAPpRBQdASJOswREPbwMbXn-H0yNU";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die("The reCAPTCHA wasn't entered correctly. Go back and try it again."); 
           } else {
			   
    	if ($year != '' && $month != '' && $day != '') {
  	  	$date = $year.'-'.$month.'-'.$day;	

	$ip = $_SERVER['REMOTE_ADDR'];
	$ver = rand(111111111,999999999);
	
	mysql_query("INSERT INTO users (`id` , `username` , `password` , `email` , `dob` , `country` , `signupdate` , `ip` , `verifictation` , `verified`)
	VALUES('' , '$user' , $pass' , '$email' , '$date' , '$country' , '$today' , '$ip' , '$ver' , 'No' ,)");
  
  
  	$subject = "Thank you for registering with The Music Network";
    $message = "$user,
    Hello $user , Almost done, just need to verify your account, here is info on how to do so.

  First off, point your browser to: musicnetwork.razor-sharpdesigns.co.uk/verify.php
  
  and enter this code: $ver 
  
  And thats all, after you can user the service fully


    Login Information:
    Username: $user
    Password: $pass

    Thanks
    The Music Network Staff.

    This is an automated response, please do not reply!";

    mail($email, $subject, $message,
        "From: The Music Network<tmn@razor-sharpdesigns.co.uk>");
   $message= 'Account created, check email. ';
} }}}}}}}}
  ?>

Did the debugging echos, it got to (original) line 5 (checking if the button had been pressed)

after that...nothing

So as far as your PHP is concerned, the form was never submitted. Would help if we could see the code you've used for the form now.

<form method="post" action="regver.php">
  <table width="80%" height="258" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
      <td width="54%" rowspan="2" align="center"><table width="80%" border="0" cellspacing="0" cellpadding="0" bordercolor="#000000">
        <tr>
          <td colspan="2" bordercolor="#000000">&nbsp;</td>
          </tr>
        <tr>
          <td width="33%" bordercolor="#000000">Username</td>
          <td width="67%" bordercolor="#000000"><label for="user"></label>
            <input type="text" name="user" id="user"></td>
        </tr>
        <tr>
          <td bordercolor="#000000">Password</td>
          <td bordercolor="#000000"><input type="password" name="pass" id="pass"></td>
        </tr>
        <tr>
          <td bordercolor="#000000">E-Mail Address</td>
          <td bordercolor="#000000"><input type="text" name="email1" id="email1"></td>
        </tr>
        <tr>
          <td bordercolor="#000000">Confirm E-Mail</td>
          <td bordercolor="#000000"><input type="text" name="email2" id="email2"></td>
        </tr>
        <tr>
          <td bordercolor="#000000">Date of Birth</td>
          <td bordercolor="#000000"><select name="month" onChange="return wait_for_load(this, event, function() { editor_date_month_change(this, 'birthday_day','birthday_year'); });">
<option value="na">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>

<select name="day">
<option value="na">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

</select>

<select name="year">
<option value="na">Year</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>

</select></td>
        </tr>
        <tr>
          <td bordercolor="#000000">Country</td>
          <td bordercolor="#000000"><select name="country">
<option value="" selected>Country...</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AG">Angola</option>

</select></td>
        </tr>
        <tr>
          <td bordercolor="#000000">Captcha</td>
          <td bordercolor="#000000"><?php 
           require_once('recaptchalib.php');
  $publickey = "6LdEqb8SAAAAAMoBAA6uhzsFuekJiexh1HEc0zgx
"; // you got this from the signup page
  echo recaptcha_get_html($publickey); ?></td>
        </tr>
        <tr>
          <td bordercolor="#000000">&nbsp;</td>
          <td bordercolor="#000000"><input type="submit" name="button" id="button" value="Submit"></td>
        </tr>
      </table></td></form>

Trimmed down alot of options, but check here for the register page in full

Hi Craig..

At line 5, you are getting this...
if ($_POST)
But, the name of the submit button is "button"...so use if($_POST)

At line 12. you used $emailc. But where did you used..

At line 22, you are using..
$email1 = stripslashes($email1);
what abt $email1..? where did you get that value..?

So far, i found out these all.. Clear these all and try once again. If still any probs, please let me know....

Line 91.

<input type="submit" name="button" id="button" value="Submit">

To:

<input type="submit" name="Submit" id="button" value="Submit">

You're checking in your PHP if a value called "Submit" is sent, however this value doesn't exist.

Ahh of course. I feel quite stupid now :$

Thanks for the help guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.