Page 1 of 1

Need a lot of help.

Posted: Tue Jun 22, 2010 3:18 pm
by ScottCFR
I've talked to a few people. I can't figure out what I've done wrong. This is kinda php/sql but yeah.

Basically, it won't post give errors or anything. you can see where I've added echo to test where my code was bad, still nothing is working. Not even the echo. I removed the CAPATCHA also and same exact thing. My host supports php so don't ask that :P

If you would like to see the uploaded page http://egcclan.info/referral/SignUp.php

Code: Select all

<?php

require_once('recaptchalib.php');
$publickey = "*";
$privatekey = "*";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# are we submitting the page?
if ($_POST["submit"]) {
  $resp = recaptcha_check_answer ($privatekey,
                                  $_SERVER["REMOTE_ADDR"],
                                  $_POST["recaptcha_challenge_field"],
                                  $_POST["recaptcha_response_field"]);

  if ($resp->is_valid) {
if(isset($_POST['submit'])) {
				echo "Works 0/5";
				$igname = $_POST['igname'];
				$steam = $_POST['steam'];
				$email = $_POST['email'];
				$ip = $_POST['ip'];
				$pass1 = $_POST['pass1'];
				$pass2 = $_POST['pass2'];
                
				$igname = mysql_real_escape_string($igname);
				$steam = mysql_real_escape_string($steam);
				$email = mysql_real_escape_string($email);
				$ip = mysql_real_escape_string($ip);
				$pass1 = mysql_real_escape_string($pass1);
				$pass2 = mysql_real_escape_string($pass2);
				
                if($igname == "" || $steam == "" || $email == "" || $pass1 == "" || $pass2 == "") {  
                    die("<p><font color='red'>Error: One or more fields are empty. Please fill them and try again.</font></p>");  
                } 
				echo "Works 2/5 ";
                if($pass != $pass2) {  
                    die("<p><font color='red'>Error: The passwords do not match.</font></p>"); 
                } 
				echo "Works 2/5 ";
                $q1 = mysql_query("SELECT * FROM `referral` WHERE `igname`='$igname'");  
                $n1 = mysql_num_rows($q1); 
                if($n1 != 0) {  
                    die("<p><font color='red'>Error: The In-Game name is already in use!</font></p>");  
                }
				echo "Works 3/5";
                $q2 = mysql_query("SELECT * FROM `referral` WHERE `email`='$email'");  
                $n2 = mysql_num_rows($q2);  
                if($n2 != 0) { 
                    die("<p><font color='red'>Error: The email address is in use by another user.</font></p>");  
                }
				echo "Works 4/5";
				$q3 = mysql_query("SELECT * FROM `referral` WHERE `steam`='$steam'");  
                $n3 = mysql_num_rows($q3);  
                if($n3 != 0) { 
                    die("<p><font color='red'>Error: The Steam ID is in use by another user.</font></p>");  
                } 
                echo "Works 5/5";
                $q3 = mysql_query("INSERT INTO `referral` (`igname`,`steam`,`email`,`ip`,`pass1`) VALUES ('$igname',$steam','$email','$ip','$pass1')") or die("<p><font color='red'>Mysql Error: <b>".mysql_error()."</b></font></p>"); 
				 
                echo "<p><font color='green'>You have signed up successfully. <a href='/index.php'>Click Here</a> to go to the home page!</font></p>";  
            }
  } else {
    # set the error code so that we can display it. You could also use
    # die ("reCAPTCHA failed"), but using the error message is
    # more user friendly
    $error = $resp->error;
  }
}
echo recaptcha_get_html($publickey, $error);
?>

Re: Need a lot of help.

Posted: Tue Jun 22, 2010 3:37 pm
by AbraCadaver
At the top:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');

Re: Need a lot of help.

Posted: Tue Jun 22, 2010 4:19 pm
by ScottCFR
Okay, got a lot fixed but don't know how to fix: Undefined index: submit (line 144)
Line 144 and up

Code: Select all

if ($_POST["submit"]) {
  $resp = recaptcha_check_answer ($privatekey,
                                  $_SERVER["REMOTE_ADDR"],
                                  $_POST["recaptcha_challenge_field"],
                                  $_POST["recaptcha_response_field"]);

  if ($resp->is_valid) {
				echo "Works 0/5";
				$igname = $_POST['igname'];
				$steam = $_POST['steam'];
				$email = $_POST['email'];
				$ip = $_POST['ip'];
				$pass1 = $_POST['pass1'];
				$pass2 = $_POST['pass2'];
                
				$igname = mysql_real_escape_string($igname);
				$steam = mysql_real_escape_string($steam);
				$email = mysql_real_escape_string($email);
				$ip = mysql_real_escape_string($ip);
				$pass1 = mysql_real_escape_string($pass1);
				$pass2 = mysql_real_escape_string($pass2);
				
                if($igname == "" || $steam == "" || $email == "" || $pass1 == "" || $pass2 == "") {  
                    die("<p><font color='red'>Error: One or more fields are empty. Please fill them and try again.</font></p>");  
                } 
				echo "Works 2/5 ";
                if($pass != $pass2) {  
                    die("<p><font color='red'>Error: The passwords do not match.</font></p>"); 
                } 
				echo "Works 2/5 ";
                $q1 = mysql_query("SELECT * FROM `referral` WHERE `igname`='$igname'");  
                $n1 = mysql_num_rows($q1); 
                if($n1 != 0) {  
                    die("<p><font color='red'>Error: The In-Game name is already in use!</font></p>");  
                }
				echo "Works 3/5";
                $q2 = mysql_query("SELECT * FROM `referral` WHERE `email`='$email'");  
                $n2 = mysql_num_rows($q2);  
                if($n2 != 0) { 
                    die("<p><font color='red'>Error: The email address is in use by another user.</font></p>");  
                }
				echo "Works 4/5";
				$q3 = mysql_query("SELECT * FROM `referral` WHERE `steam`='$steam'");  
                $n3 = mysql_num_rows($q3);  
                if($n3 != 0) { 
                    die("<p><font color='red'>Error: The Steam ID is in use by another user.</font></p>");  
                } 
                echo "Works 5/5";
                $q3 = mysql_query("INSERT INTO `referral` (`igname`,`steam`,`email`,`ip`,`pass1`) VALUES ('$igname',$steam','$email','$ip','$pass1')") or die("<p><font color='red'>Mysql Error: <b>".mysql_error()."</b></font></p>"); 
				 
                echo "<p><font color='green'>You have signed up successfully. <a href='/index.php'>Click Here</a> to go to the home page!</font></p>";  
            }
  } else {
  
    die ("reCAPTCHA failed");
	}

echo recaptcha_get_html($publickey, $error);
?>
				  <p><br />
                    <input type="submit" value="Sign Me Up!" />
                    <br />
                  </p>
            </form>

Re: Need a lot of help.

Posted: Tue Jun 22, 2010 4:24 pm
by AbraCadaver

Code: Select all

if(isset($_POST['submit']))

Re: Need a lot of help.

Posted: Tue Jun 22, 2010 4:59 pm
by ScottCFR
I knew it looked funny, that's what it was. Thanks :D

Re: Need a lot of help.

Posted: Wed Jun 23, 2010 2:00 pm
by ScottCFR
I am still having the issue. No errors. No post, nothing.

Anyone help. (Code is still above :D)

Re: Need a lot of help.

Posted: Wed Jun 23, 2010 2:31 pm
by AbraCadaver
Your else statement is matched with the wrong if statement. It is currently matched with:

Code: Select all

if ($_POST["submit"]) {
But it should be matched with:

Code: Select all

if ($resp->is_valid) {