Jump to content

Recommended Posts

that worked but its not working properly:

 

i have this piece of code->

 

$insert['username'] = $_POST['username'];
	$insert['name'] = $_POST['username'];
	$insert['password'] = $password;
	$insert['email'] = $_POST['email'];
	$insert['registered'] = time();
	$insert['last_active'] = time();
	$insert['ip'] = $_SERVER['REMOTE_ADDR'];
	$insert['validkey'] = $string;
	if ($_GET['ref'] >= 1){
	$insert['ref'] = $ref_id;
	}
	$query = $db->autoexecute('players', $insert, 'INSERT');

 

but its not setting ref to $ref_id.

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1000838
Share on other sites

I would have expected to see

 

if ($_GET['ref'] >= 1)

{

      $ref_id = $_GET['ref'];

      $insert['ref'] = $ref_id;

}

 

or even

 

if ($_GET['ref'] >= 1)

{

      $insert['ref'] = $_GET['ref'];

}

 

okay i have replaced it inside the if statement like you showed..

 

ill give it a test and see what happens.

 

<?php
	$insert['username'] = $_POST['username'];
	$insert['name'] = $_POST['username'];
	$insert['password'] = $password;
	$insert['email'] = $_POST['email'];
	$insert['registered'] = time();
	$insert['last_active'] = time();
	$insert['ip'] = $_SERVER['REMOTE_ADDR'];
	$insert['validkey'] = $string;
	if ($_GET['ref'] >= 1)
	{
	$ref_id = $_GET['ref'];
	$insert['ref'] = $ref_id;
	}
	$query = $db->autoexecute('players', $insert, 'INSERT');
?>

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1000952
Share on other sites

?ref=10

if ($_GET['ref'] >= 1){
      $insert['ref'] = $_GET['ref'];
}
echo $insert['ref'];

 

should result in

10

 

that didnt echo anything for me.

 

 

Ok so, that means that ref is being set.

 

So, let us make sure that the $insert array is being populated correctly

 

Just before you call the query, do print_r($insert) to see what is getting in there

 

i put it just before the if statement and got:

 

Array ( [username] => sean2 [name] => sean2 [password] => md5 password => ss2@mafiakiller.com [registered] => 1264375687 [last_active] => 1264375687 [ip] => 94.2.58.23 )

 

 

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1000981
Share on other sites

okay lets go back to basics

 

what do you get from this ?

if ($_GET['ref'] >= 1){
      $insert['ref'] = $_GET['ref'];
}
echo $insert['ref'];
print_r($_GET);

 

better still try this

if (!empty($_GET['ref']) && $_GET['ref'] >= 1){
      $insert['ref'] = $_GET['ref'];
}
echo $insert['ref'];
print_r($_GET);

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1000984
Share on other sites

okay so i placed it inside the if statement after the $insert[ref] and it showed the exact same print:

 

Array ( [username] => sean2 [name] => sean2 [password] => md5 password  => ss2@mafiakiller.com [registered] => 1264375687 [last_active] => 1264375687 [ip] => 94.2.58.23 )

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1000985
Share on other sites

okay lets go back to basics

 

what do you get from this ?

if ($_GET['ref'] >= 1){
      $insert['ref'] = $_GET['ref'];
}
echo $insert['ref'];
print_r($_GET);

 

better still try this

if (!empty($_GET['ref']) && $_GET['ref'] >= 1){
      $insert['ref'] = $_GET['ref'];
}
echo $insert['ref'];
print_r($_GET);

 

i tried the second one you gave and it showed this: Array ( )

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1000986
Share on other sites

im using a live host...

 

and php otherwise works fine..

 

this is the entire page:

 

<?php
ob_start();
/*******************************************/
/*       Development / Maintanence         
/*             by  Seany123	           
/*                 for	                   
/*              [REMOVED URL]           
/*******************************************/

include("lib.php");
define("PAGENAME", "Register");

include("templates/header.php");

srand((double)microtime()*1000000);  //sets random seed
$string = md5(rand(0,1000000));

$msg1 = "<font color=\"red\">"; //Username error?
$msg2 = "<font color=\"red\">"; //Password error?
$msg3 = "<font color=\"red\">"; //Verify Password error?
$msg4 = "<font color=\"red\">"; //Email error?
$msg5 = "<font color=\"red\">"; //Verify Email error?
$error = 0;

$ip = $_SERVER['REMOTE_ADDR'];

if ($_POST['register'])
{

$username = ($_POST['username']);
$password = md5($_POST['password']);

//Check if ip has already been used
$query = $db->execute("select `ip` from `players` where `ip`=?", array($ip));
    if ($query->recordcount() > 0)
{
echo "Sorry, but you can't sign up because the IP address you are using is already being used on another account!";
		echo "<br><br><a href=\"index.php\">[back]</a></table></div></div>";

    		//Include ADVERT PAGE
    		include ("advert.php");
		echo "</div>";
		exit;
}

//Check if username has already been used
$query = $db->execute("select `id` from `players` where `username`=?", array($_POST['username']));
//Check username
if (!$_POST['username']) { //If username isn't filled in...
	$msg1 .= "You need to fill in your username!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if (strlen($_POST['username']) < 3)
{ //If username is too short...
	$msg1 .= "Your username must be longer than 3 characters!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if (!preg_match("/^[-_a-zA-Z0-9]+$/", $_POST['username']))
{ //If username contains illegal characters...
	$msg1 .= "Your username may contain only alphanumerical characters!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if ($query->recordcount() > 0)
{
	$msg1 .= "That username has already been used. Please create only one account, Creating more than one account will get all your accounts Banned!<br />\n";
	$error = 1; //Set error check
}

//Check password
if (!$_POST['password'])
{ //If password isn't filled in...
	$msg2 .= "You need to fill in your password!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if ($_POST['password'] != $_POST['password2'])
{
	$msg3 .= "You didn't type in both passwords correctly!<br />\n";
	$error = 1;
}
else if (strlen($_POST['password']) < 3)
{ //If password is too short...
	$msg2 .= "Your password must be longer than 3 characters!!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if (!preg_match("/^[-_a-zA-Z0-9]+$/", $_POST['password']))
{ //If password contains illegal characters...
	$msg2 .= "Your password may contain only alphanumerical characters!<br />\n"; //Add to error message
	$error = 1; //Set error check
}

//Check email
if (!$_POST['email'])
{ //If email address isn't filled in...
	$msg4 .= "You need to fill in your email!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if ($_POST['email'] != $_POST['email2'])
{
	$msg5 .= "You didn't type in both email address correctly!";
	$error = 1;
}
else if (strlen($_POST['email']) < 3)
{ //If email is too short...
	$msg4 .= "Your email must be longer than 3 characters!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else if (!preg_match("/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i", $_POST['email']))
{
	$msg4 .= "Your email format is wrong!<br />\n"; //Add to error message
	$error = 1; //Set error check
}
else
{
	//Check if email has already been used
	$query = $db->execute("select `id` from `players` where `email`=?", array($_POST['email']));
	if ($query->recordcount() > 0)
	{
		$msg4 .= "That email has already been used. Please create only one account, Creating more than one account will get all your accounts banned!<br />\n";
		$error = 1; //Set error check
	}
}

if ($error == 0)
{
	$insert['username'] = $_POST['username'];
	$insert['name'] = $_POST['username'];
	$insert['password'] = $password;
	$insert['email'] = $_POST['email'];
	$insert['registered'] = time();
	$insert['last_active'] = time();
	$insert['ip'] = $_SERVER['REMOTE_ADDR'];
	if (!empty($_GET['ref']) && $_GET['ref'] >= 1){
	$insert['ref'] = $_GET['ref'];
	}
	echo $insert['ref'];
	print_r($_GET);
	$insert['validkey'] = $string;
	$query = $db->autoexecute('players', $insert, 'INSERT');

	if (!$query)
	{
		$could_not_register = "Sorry, you could not register! Please contact the admin!<br /><br />";
	}
	else
	{
	$insertid = $db->Insert_ID();
                        $email=$_POST['email'];
                        $thekey=$string;
                        $user = $_POST['username'];
                        $pass = $_POST['password'];
                        $subject = '[REMOVED URL] Activation!';
                        $message = "Thank you for registering at [REMOVED URL], please activate your account at:
					http://[REMOVED URL]/validate.php?email=$email&string=$string 
                        
                        You can login to the game after activating account at: http://www.[REMOVED URL] 

					with the following details: 

					Username: $user  
					password: $pass  

					Best Regards 
					[REMOVED URL] Admin Team.";
                        $headers = "From: admin@[REMOVED URL]\r\nReply-To: admin@[REMOVED URL]";
                        mail($_POST['email'], $subject, $message, $headers);

		echo "Congratulations! You have successfully registered!<br />You will recieve an email to activate account.";
		echo "<br><br><a href=\"index.php\">[back]</a>";
    		//Include ADVERT PAGE
    		include ("advert.php");
		echo "</div>";
		exit;
	}
}
}


$msg1 .= "</font>"; //Username error?
$msg2 .= "</font>"; //Password error?
$msg3 .= "</font>"; //Verify Password error?
$msg4 .= "</font>"; //Email error?
$msg5 .= "</font>"; //Verify Email error?
$msg6 .= "</font>"; //Verify IP error?

?>

<?=$could_not_register?>

<html>
<head>
<title>[REMOVED URL]</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/css/style.css" type="text/css" media="all" />	
</head>
<body alink="#cc9900" vlink="#cc9900" link="#cc9900">
<div id="left_c">
<div class="g_content"><h3 style="text-align: left">  [REMOVED URL]</h3><div class="g_text">	<table width='100%'>
Welcome to [REMOVED URL], A new Mafia based game.
Your role in [REMOVED URL] is simple, become the best!
whether its being the top leveled mobster, Gang leader, Mugger or Exp Bunny.
<br>
<b>FEATURES INCLUDE:</b>
<br>
* Unique Mugging system.
<br>
* Unique Battle System.
<br>
* varitiy of different Houses.
<br>
* 20+ Different Crimes.
<br>
* 27 different Cities.
<br>
* Create Your own Gang.
</table></div></div>

<div class="g_content"><h3 style="text-align: left">  Attention</h3><div class="g_text">	<table width='100%'>
Unfortunatly [REMOVED URL] is not supported by Internet Explorer.
<br>
Please use one of the following to play [REMOVED URL]:
<br>
<a href=\"http://www.google.com/chrome\">* Google Chrome</a>
<br>
<a href=\"http://www.mozilla.com/firefox\">* Mozilla FireFox</a>
<br>
</table></div></div>

<div class="g_content"><h3 style="text-align: left">  Register</h3><div class="g_text"><table width='100%'>

<form method="POST" action="register.php">
<table width="100%">
<tr><td width="40%"><b>Username</b>:</td><td><input type="text" name="username" value="<?=$_POST['username'];?>" /></td></tr>
<td colspan="2"><?=$msg1;?></td>

<tr><td width="40%"><b>Password</b>:</td><td><input type="password" name="password" value="<?=$_POST['password'];?>" /></td></tr>
<td colspan="2"><?=$msg2;?></td>

<tr><td width="40%"><b>Verify Password</b>:</td><td><input type="password" name="password2" value="<?=$_POST['password2'];?>" /></td></tr>
<td colspan="2"><?=$msg3;?></td>

<tr><td width="40%"><b>Email</b>:</td><td><input type="text" name="email" value="<?=$_POST['email'];?>" /></td></tr>
<td colspan="2"><?=$msg4;?></td>

<tr><td width="40%"><b>Verify Email</b>:</td><td><input type="text" name="email2" value="<?=$_POST['email2'];?>" /></td></tr>
<td colspan="2"><?=$msg5;?></td>
<br>
<tr><td colspan="2">
By signing up, you agree that you have read and accept the <a href="tos.php">Terms of Service</a>.<br>
<tr>
<td>
</td>
<td>
<input type="submit" name="register" value="Register!"></td></tr>
</table>
</form>
</div>
</div>
    <?php
    //Include ADVERT PAGE
    include ("advert.php");
    ?>
</div>	
</html>
[code]

maybe i have done something wrong.

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1001000
Share on other sites

As i said,

You didn't pass anything in the URL.. add ?ref=10 to it!

 

for that form to process you need to POST the form BUT the form is NOT passing the get

<form method="POST" action="register.php">

 

for example try

<form method="POST" action="register.php?ref=10">

Link to comment
https://forums.phpfreaks.com/topic/189633-why-wont-this-echo/#findComment-1001006
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.