My register page does not register to mysql

when i register, it just reloads the page and does not update an account on my sql, could anyone help me with this please :slight_smile: i could also send it on a note pad because i don’t know how to space it out on this website sorry :frowning:

This is the top part of my page Register.php

<?PHP


include "heresmyconnect.php";
$datetime = gmdate('Y-m-d h:i:s');
    indent preformatted text by 4 spaces
    indent preformatted text by 4 spaces

function change($msg){
$post = $msg;
$post = str_replace(" ", "", $post); 
return $post;
}

if ($_POST['Submit'] && change(strip_tags($_POST['username'])) && change(strip_tags($_POST['password']))){



$ip=$_SERVER['REMOTE_ADDR']; //draws IP address of visitor
$ref=mysql_real_escape_string(strip_tags($_GET['ref']));



//This of course tells the website that what follows
$realip=$_SERVER['REMOTE_ADDR'];


if (ereg('[^0-9]', $ref)){$ref="0";}


$email1 = $_POST['email']; 
$email2 = change(mysql_real_escape_string($email1));
$email = ($email2);
$username1 = $_POST['username']; 
$username2 = strip_tags($username1);
$username = change(mysql_real_escape_string($username2));
$password1 = $_POST['password']; 
$password2 = strip_tags($password1);
$password = change(mysql_real_escape_string($password2));

$checkname = mysql_query("SELECT * FROM users WHERE username='$username'");
$NameCount = mysql_num_rows($checkname);

if ($NameCount > 0)
{
	echo "<font color=red>The username is already in use, Please choose another!</font>";
}else{




$result = mysql_query("SELECT * FROM registerip") or die("Hack protection error Please contact [email protected]  and tell him about this!");
// keeps getting the next row until there are no more to get
	while($row = mysql_fetch_array( $result )) {

$id = $row['id'];
$timeleft = $row['time'] - time();


if ($timeleft <0){mysql_query("DELETE FROM registerip WHERE id='$id'");}

}// while loop





$rresult = mysql_query("SELECT * FROM registerip WHERE ip='$realip'");
$rrow = mysql_num_rows($rresult);


if($rrow >= "2"){
die("your ip has registered a account a little while a go, Please wait before you can register another!");
}



if (ereg('[^A-Za-z0-9]', $username)) {echo "<font color=white>Your username can only contain A-Z,a-z and 0-9.</font>";}else{
$randompin129 = rand(1,54785412);

$otime=time();

mysql_query("INSERT INTO `users` ( `id` , `username` , `password` , `email` ,`ip`,`referedby`,`pin`) VALUES ('', '$username', '$password', '$email', '$ip', '$ref', '$randompin129')");
mysql_query("INSERT INTO `times` ( `username` ) VALUES ('$username')");

mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
'', '$username', 'Natasha', 'HEY <br> Do me a faviour, Kill Tyler for me, he is chatting shit about me<br>If you kill him you will be paid nicely ;)</b>', '$date', '0', '0')");

mysql_query("INSERT INTO `messages` ( `id` , `t` , `f` , `message` , `date` , `r` , `saved` ) VALUES (
'', '$username', 'MrSecret', 'Your password Recovery Pin is $randompin129 Please remember this, incase you forget your password. You can change this by going into the profile section.', '$date', '0', '0')");



$sql = "INSERT INTO registerip SET id = '', ip = '$realip', time = '".strtotime ("+10 minutes")."'";
$res = mysql_query($sql);  
    

// Automatically collects the hostname or domain  like example.com) 
$host  = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');

Admin Edit: Added Code tags

if anyone knows how i can change this text so that you can scroll down it like how it is in my file manager all spaced out i will update it

I did it for you. Use the code tags Icon </>

Thank you admin :slight_smile: is there any chance you know what is wrong with my script also :slight_smile:

So first thing, your code is way outdated. Mysql_* has been completely removed from Php. You need to use PDO with Prepared Statements. This tutorial will get you going.
https://phpdelusions.net/pdo

If you can actually run that code, then your PHP version is severely outdated. You need to update to a current version.

1 Like

i can run the whole website code everything works just not my register page, i done a test site on a free host here ( http://mafiadon.mipropia.com/Register.php )

that link you gave me is a very very big page :frowning: is there anychance you could fix it for me, i’m willing to pay you for your service :smiley:

Your code is not fixable. It is highly insecure and support for it has been completely removed from Php. You need to update your code. No one should help you get dangerous code “working”.

If you like, I can do a re-write in PDO. PM me a zip file of ALL your code and I will see what is needed.

Wow! thank you benanmen! i’ll get that sent over for you now :smiley: :smiley:

Sorry to sound like the biggest noob on this website but could you give me an url to your pm, i can’t seem to find it, i have all my files downloaded and zipped ready :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service