note 109725 rejected from function.mcrypt-module-open by aharvey
| From: | aharvey@php.net | Date: | Wed, 15 Aug 2012 01:51:36 +0000 |
| Subject: | note 109725 rejected from function.mcrypt-module-open by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190074@lists.php.net to get a copy of this message | ||
Note Submitter: kelvin dot sg at gmail dot com
----
hi all !
I need the expertise here, i been through many resources yet could not find the answer.
i am working on simple a login script with user registration, but could not find much help/
i would like to use 3des encryption on the passwords for new user registration, and able to login
after registering.
here goes my script.
create_user.php
<?php
require 'C:\xampp\htdocs\myphp\course\scripts\database_connection.php';
// Get the user's information from the request into variables
?>
<?php
$username = ($_REQUEST['username']);
$password = ($_REQUEST['password']);
//$password = md5($password);
$email = trim($_REQUEST['email']);
//My testing
//end testing
// Handle user request
$insert_sql = "INSERT INTO members (username, password, email) " .
"VALUES ('{$username}', '{$password}', '{$email}');";
// Insert the user into the database
mysql_query($insert_sql);
?>
checklogin.php
<?php
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="123"; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot
connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and
password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
if(empty($myusername)){
$myusername = 'here the problem';
}
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
header("location:login_success.php");
}
else {
echo "Please Try Again";
}
?>
app_config.php
<?php
// Database connection constants
define("DATABASE_HOST", "localhost");
define("DATABASE_USERNAME", "root");
define("DATABASE_PASSWORD", "123");
define("DATABASE_NAME", "test");
// Error reporting
error_reporting(E_ALL);
?>
Kindly assist