PDA

View Full Version : register form problem



jangkoo
07-24-2010, 06:33 AM
Hi friends,
I have 1 problem with registration form
the code is here

<center>
<div align="left">
<form action="buffered_register.php" method=post enctype="multipart/form-data">
<fieldset>
<p><a> Name</a>
<input type=text size=40 name="real_name" />
<br /> Age
<input type=text size=10 name="age" />
<br>Username</br>
<input type=text size=40 name="user_name" />
<br /> Password
<input type=password size=10 name="pass_word" />
<br /> Email
<input type=text size=40 name="email" />
<br /> Current Address
<input type=name size=40 name= "location" />
<br /> Upload Avatar
<input type=file name="avatar">
</p>
</fieldset>
<p>
<input style=" background-color:#0F6" type=submit name=ok value="OK all" />
</p>
</form>
</div>
</center>


the bufferedregister.php

<?php
include ("dbconnect1.php");
header("Content-type: image/jpeg");
header("location: index.php");

$name=$_POST['real_name'];
$age=$_POST['age'];
$username=$_POST['user_name'];
$password=$_POST['pass_word'];
$email=$_POST[email];
$location=$_POST['location'];
// THIS CODE FOR UPLOAD AVATAR
move_uploaded_file($_FILES["avatar"]["tmp_name"],
"img/upload/avatar/" . $_FILES["avatar"]["name"]);
$url="img/upload/avatar/" . $_FILES["avatar"]["name"];


$sql="select * from guestbook where user_name='".$username."'";
$query=mysql_query($sql);
$count=0;
while($row=mysql_fetch_array($query)){$count++;}
//if(msql_num_rows($sql))
if($count==0)
{
$query="insert into guestbook(name,age,address,user_name,password,email,image) values ('$name','$age','$location','$username','password','$email','$url')";
mysql_query($query) or die(mysql_error());
}

and table guestbook

Field Type Null Default Comments
name varchar(20) No noname
user_name varchar(20) No noname
password varchar(20) No 111111
age varchar(20) No 000000
address varchar(20) No noaddress
id int(20) No
email varchar(20) No noemail
image varchar(50) No
Indexes: Documentation
Keyname Type Unique Packed Field Cardinality Collation Null Comment
PRIMARY BTREE Yes No id 10 A


the problem is password input. Whatever passwords users input, they will be inserted to database as "password". Other fields work well.
So what is the problem ?
Can someone point it out for me?
thanks.

ashokmhrj
07-24-2010, 07:29 AM
in php

$email=$_POST['email'];

you forget to put '$' sign in password:
$query="insert into guestbook(name,age,address,user_name,password,email,image) values

('$name','$age','$location','$username','$password','$email','$url')";
mysql_query($query) or die(mysql_error());

jangkoo
07-24-2010, 08:03 AM
OMG. Thank you very much. I tried to figure it out but couldnt see that.
:-<.
Thanks alot.