I have an html form which has 2 fields realuser and useremail it then submits on the php page .i have a database table named auth .my database has 3 fields i.e realuser,useremail and details ,in which i have filled "details" field already and rest 2 fields are blank.i have php script which insert the 2 fields submitted via html form in database.

i want when user submits the form, it then insert the 2 fields into table named "auth". i want that when user fills it then automatically the data from details field sent to the email id taken from "useremail" field.

BUT i an facing the problem that when user submit the form.the database filled with same "realuser" and "usermail"..for example i fill "john" and "ab@bb.com" in html form and then submit..then when i see the database it filled john and ab@bb.com all over the table.

my code is :

<?php
// Connects to your Database

mysql_connect("localhost", "john", "nicho123") or die(mysql_error());

mysql_select_db("john_321") or die(mysql_error());

echo "connected to database";

$update = "UPDATE auth SET realuser = '".$_POST."' , realpass = '".$_POST."' ";

mysql_query($update);

?>


PLEASE HELP ME.. :(

THNX IN ADVANCE :)

Hi

I think the problem is due to the absence of where condition. Pls check it

when the program comes to update query.it fills all the rows with john and [email]ab@bb.com....if[/email] it fills one row then i can place where clause to mail the details from userdetails "field"...i am frustated :(

I think ditty was right. There should be "Where" in the query so that the script can identify the record you want to update.

Something like this.

<?php 
// Connects to your Database 

mysql_connect("localhost", "john", "nicho123") or die(mysql_error()); 

mysql_select_db("john_321") or die(mysql_error()); 

echo "connected to database";

$update = "UPDATE auth SET auth.realuser = '$_POST[realuser]' where usermail='$_POST[usermail]'";
$update = "UPDATE auth SET auth.realpass = '$_POST[realpass]' where usermail='$_POST[usermail]'"; 

mysql_query($update);

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.