mysql - After login in to the profile how to insert some other columns data into same database in php -
i have signup form. once create form data inserted registered table once after login form need fill details , insert same columns comparing mail ids. when i'm trying insert data showing not inserted database.
dashboard.php:
<form method="post" action="personalinfo.php" id="myform"> <input type='hidden' value="<?php echo $_get['email'];?>" name='email'> <div> <label for="first-name">first name<span class="mandatory">*</span></label> <input id="first-name" type="text" name="first-name" value="" /> </div> <button type="submit" id = "submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> save</button>
personalinfo.php:
<?php $connection = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("accountant", $connection); $email=$_post['email']; $firstname = $_post['first-name']; $query = mysql_query("insert registered (first-name) values ('$firstname') select email registered email!='$email' "); mysql_query("$query") or die("error:".mysql_error()); if($query) { echo "successfully registered"; } else{ echo "registration has not been completed.please try again"; } ?>
if use mysql_error showing query empty.
this complete set of answer comments.
<?php $connection = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("accountant", $connection); $email=$_post['email']; $firstname = $_post['first_name']; // check if email registered $res = mysql_query("select email registered email='$email"); if(!$res || mysql_num_rows($res)<1){ // if not add record $query = mysql_query("insert registered (first_name, email) values ('$firstname', '$email')") or die("error:".mysql_error()); }else{ // if email present update record $query = mysql_query("update registered set first_name='$firstname'" email= '$email') or die("error:".mysql_error()); } if($query) { echo "successfully registered"; } else{ echo "registration has not been completed.please try again"; } }
Comments
Post a Comment