Jump to content

Data is not inersting to mysql any help?


luckyimran111

Recommended Posts

I'm making this Registration form but After pressing Submit button I did not get data in mysql database so here is my all code any one will help meRegistration_form.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Registration Form</title></head><body><body><table width="200" border="0" align="center"><form id="form1" name="form1" method="post" action="registration_script.php"><tr><td colspan="2"><h2 style="color:#FF0000">Registration Form</h2></td></tr><tr><td>UserName:</td><td><input type="text" name="txtUser" id="txtUser" /></td></tr><tr><td>Password:</td><td><input type="password" name="txtPassword" id="txtPassword" /></td></tr><tr><td colspan="2" align="center"><input type="submit" name="btnRegister" id="btnRegister" value="Register" /></td></tr></form></table></body></html></body>

here is registraion_script.php

<?php//=============Configuring Server and Database=======$host		=	'localhost';$user		=	'root';$password	=	'';//=============Data Base Information=================$database	=	'test'; $conn		=	mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Servermysql_select_db($database,$conn) or die('Database Information is not correct'); //===============End Server Configuration============ //=============Starting Registration Script========== $userName	=	$_POST['txtUser']; $password	=	$_POST['txtPassword']; //=============To Encrypt Password===================$password	=	md5($password);//============New Variable of Password is Now with an Encrypted Value======== if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register{$query	=	"insert into test(username,password)values('$userName','$password')";$res	=	mysql_query($query);header('location:success_register.php');} ?>

***** any COMMENT WILL BE USEFUL FOR ME >>> SO PLEASE COMMENT ON IT ALSO

Edited by luckyimran111
Link to comment
Share on other sites

First of all, you should be checking whether the query worked or not and find out why using mysql_error().

$query	=	"insert into test(username,password)values('$userName','$password')";$res	=	mysql_query($query);if(!$res) {	echo mysql_error();} else {	header('location:success_register.php');}

On a side note, MD5 is considered insufficient protection for passwords today.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...