mysql - how to post contact no. to sql database using php -
i want store user's contact no. android registration form in sql database shows 'failure' instead of 'success' when try add $_post['contact'] code php file. php file.
register.php
<?php define('host','mysql8.000webhost.com'); define('user','a6293046_******'); define('pass','*********'); define('db','a6293046_insti'); $con = mysqli_connect(host,user,pass,db); $name = $_post['name']; $email = $_post['email']; $address = $_post['address']; $contact =(int)$_post['contact']; $institute = $_post['institute']; $sql = "insert persons (name,email,address,contact-no,institute) values ('$name','$email','$address','contact-no','$institute')"; if(mysqli_query($con,$sql)){ echo 'success'; } else{ echo 'failure'; } mysqli_close($con); ?>
please tell me doing wrong in it. thank you
<?php define('host','mysql8.000webhost.com'); define('user','a6293046_******'); define('pass','*********'); define('db','a6293046_insti'); $con = mysqli_connect(host,user,pass,db); $name = $_post['name']; $email = $_post['email']; $address = $_post['address']; $contact =$_post['contact']; $institute = $_post['institute']; $sql = "insert persons (name,email,address,contact-no,institute) values ('$name','$email','$address',$contact,'$institute')"; $result=$con->query($sql); if($result) { echo 'success'; } else{ echo 'failure'; } $con->close(); ?> remove int $post_['contact'] , dnt use single quotes('') $contact while inserting since integer string value should give single quotes
Comments
Post a Comment