Jump to content


Photo

please help


  • Please log in to reply
26 replies to this topic

#21 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 24 July 2006 - 01:32 PM

well that can fixed by doing this



$sql = "INSERT INTO login_tbl (loginid, password, email) VALUES ('$loginid', '$password', '$email')";

if(!$sql){ 
    echo 'There has been an error creating your account. Please contact the webmaster.'; 
}else{
    echo " Your account has now been created. You may login with the following information:<br>
	<b>Login Id :</b> $loginid <br>
	<b>Password</b> $password <br>"; 
}		 	  
?>



or you can use this scipt that I just wrote for you

<?php
include('db.php');//your database connection file
array_pop($_POST);
if ( get_magic_quotes_gpc() ) {
    $_POST= array_map('stripslashes', $_POST);
}
$loginid = mysql_real_escape_string(trim($_POST['loginid']));
$email = mysql_real_escape_string(trim($_POST['email']));
$password = mysql_real_escape_string(trim($_POST['password']));

//lets check to see if all of the information was entered
if ((!$loginid) || (!$email) || (!$password)) {
    echo "You did not submit the following information<br>";
    if (!$loginid) {
        echo "<b><i>Login Id is a required field!</i></b><br>";
    }
    if (!$email) {	
        echo "<b><i>Email is a required field</i></b><br>";
    }
    if (!password) {
        echo "<b><i>Password is a required field</i></b><br>";
    }
    include('register.html');
    exit();
}

//check to see if the login id or email is already being used
$loginid_sql = sprintf("SELECT COUNT(*) AS loginid_match FROM `login_tbl ` WHERE `loginid` = '%s'", $login_id);
$email_sql = sprintf("SELECT COUNT(*) AS email_match FROM `login_tbl ` WHERE `email` = '%s'", $email);

$loginid_result= mysql_query($loginid_sql) or die(mysql_error());
$email_result= mysql_query($email_sql) or die(mysql_error());

$loginid_match= mysql_result($loginid_result, 0, 'loginid_match');
$email_match= mysql_result($email_result, 0, 'email_match');

if ( $loginid_match > 0 ) { //if there are any login ids that match
     echo "This login id is already taken. Please try again";
     include('register.html');//your register form
     unset($loginid);
     exit();
}
if ( $email_match > 0 ) { //if there are any email addresses that match
     echo "This email has already been used";
     include('register.html');//your register form
     unset($email);
     exit();
}

$mdpwd = md5($password);
$sql = mysql_query("INSERT INTO login_tbl (loginid, password, email) 
       VALUES ('$loginid', '$mdpwd', '$email')");
if(!$sql){ 
    echo 'There has been an error creating your account. Please contact the webmaster.'; 
}else{
    echo " Your account has now been created. You may login with the following information:<br>
	<b>Login Id :</b> $loginid <br>
	<b>Password</b> $password <br>"; 
}		 	  
?>

Good luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#22 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 01:41 PM

omg mate, u r a legend! thankyou very much i will try both!

#23 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 24 July 2006 - 02:37 PM

Parse error: parse error, unexpected $ in register.php on line 73

i used the script u wrote me, and i got that error?

#24 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 24 July 2006 - 06:28 PM

Check this. I just copied and pasted the script into both a text editor and into a coding program. When copying and pasting it the last few lines are broken. Like this:

<b>Login Id :</b> $loginid <br>

	d</b> $password <br>"; 


<b>Passwor

When it should look like this:

echo " Your account has now been created. You may login with the following information:<br>";
	echo "<b>Login Id :</b> $loginid <br>";
	echo "<b>Password</b> $password <br>";

tomfmason, I don't mean to change your code. I'm just a noob. But what I'm pointing out is that the last echo statement you wrote that displays the username/password for some reason wouldn't copy and paste properly and was producing broken syntax errors 'as is' because of that. So, I changed it to 3 separate echo statements just to make sure it worked. I'm thinking that perhaps that's what happened to onthespot in his attempt to copy/paste and execute the code. Just a guess :)



#25 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 25 July 2006 - 12:47 PM

cheers mate, ill try this now

#26 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 25 July 2006 - 01:56 PM

it was not the echo but rather that I forgot a } at the end. Change the end of the script to this

if(!$sql){ 
    echo 'There has been an error creating your account. Please contact the webmaster.'; 
}else{
    echo " Your account has now been created. You may login with the following information:<br>
	<b>Login Id :</b> $loginid <br>
	<b>Password</b> $password <br>"; 
}		 	  
?>


Here is a login script

<?php
session_start(); 
include ('includes/db.php');
array_pop($_POST); 
if ( get_magic_quotes_gpc() ) { 
    $_POST= array_map('stripslashes', $_POST); 
} 
$loginid= mysql_real_escape_string(trim($_POST['loginid'])); 
$password= mysql_real_escape_string(trim($_POST['password']));
$mdpwd= md5($password); 

$sql= sprintf("SELECT COUNT(*) AS login_match FROM `login_tbl` WHERE `loginid` = '%s' AND `password`= '%s'", $loginid, $mdpwd); 
$res= mysql_query($sql) or die(mysql_error()); 
$login_match= mysql_result($res, 0, 'login_match'); 

if ( $login_match == 1 ) { 
    $_SESSION['loginid']= "$loginid";
    $login_id = $_SESSION['loginid'];
    echo " Welcome $login_id, you are now loged in. <a href=\"http://www.yoursite.com/yourpage.php\">Click here</a> to proceed";
    
} else { 
    echo "Your password and username do not match. Please try again.";
	include('your_login_form.html');//change this to your login form
	// not logged in 
}
?>

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#27 onthespot

onthespot
  • Members
  • PipPipPip
  • Advanced Member
  • 424 posts

Posted 25 July 2006 - 11:03 PM

i spotted the } u missed out mate, and got it working ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users