php - linking and sending form values to mysql database? -


my html code:

<form action="send_post.php" method="post">     <input type="submit" value="login" /> </form> 

php code:

<?php $con = mysqli_connect("","",""); if (!$con) { die('could not connect: ' . mysql_error()); } else { // echo('connected mysql'); } @mysql_select_db("a", $con);// connect database db_name if (isset($_post['submit'])) { $email=$_post['email'];   $pass=$_post['pass'];  $sql_query="insert formdata (email, pass) values('$email', '$pass')";} ?> 

database name: mysql table name: formdata

why not working? in second line used 'local host' first receiving error removed it.

  1. you use mysqli_ api connect database , test errors , try select database mysql_ api. pick 1 , stick it. (don't pick mysql_ deprecated).
  2. you run form handling code if there submit data item in submitted data. have no form control name="submit" never happen.
  3. your form handling code expects there email , pass data in submitted data form not have fields names.
  4. constructing sql query string , storing in variable insufficient database. have sent database server. use mysqli_query current approach, should switch prepared statements

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -