Need a lot of help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ScottCFR
Forum Commoner
Posts: 33
Joined: Sat Jun 19, 2010 7:36 pm

Need a lot of help.

Post 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);
?>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Need a lot of help.

Post by AbraCadaver »

At the top:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
ScottCFR
Forum Commoner
Posts: 33
Joined: Sat Jun 19, 2010 7:36 pm

Re: Need a lot of help.

Post 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>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Need a lot of help.

Post by AbraCadaver »

Code: Select all

if(isset($_POST['submit']))
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
ScottCFR
Forum Commoner
Posts: 33
Joined: Sat Jun 19, 2010 7:36 pm

Re: Need a lot of help.

Post by ScottCFR »

I knew it looked funny, that's what it was. Thanks :D
ScottCFR
Forum Commoner
Posts: 33
Joined: Sat Jun 19, 2010 7:36 pm

Re: Need a lot of help.

Post by ScottCFR »

I am still having the issue. No errors. No post, nothing.

Anyone help. (Code is still above :D)
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Need a lot of help.

Post 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) {
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply