HAI,, WHEN I USING THE BELOW SCRIPT FOR INSERTING ... Aug 13th 2013, 12:25, by Renu Philip Puthenpurackal | HAI,, WHEN I USING THE BELOW SCRIPT FOR INSERTING VALUES INTO THE DATA BASE THE NUMBER "1" IS INSERTED IN DATA BASE,WHY..? NO OTHER VALUES DONOT ENTER INTO THE DATA BASE <?php $con=mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db("hotel",$con); $name=isset($_POST['name']); $sub=isset($_POST['subject']); $email=isset($_POST['email']); $phone=isset($_POST['phone']); $comment=isset($_POST['inquiry']); if(isset($_POST['submit'])) { $sql="INSERT INTO contact(name,subject,email,phone,comment) VALUES('".$name."','".$sub."','".$email."','".$phone."','".$comment."')"; $result=mysql_query($sql); if($result) { echo "<script type='text/javascript'>javascript:alert('message send.'); window.location='contact.php';</script>"; exit; } } mysql_close($con); ?> |
| | . is problem |
| | isset is the problem.. isset is conditional not return string... btw.. USE mysqli |
| | check your variable, or replace your code as below. <?php $con=mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db("hotel",$con); $name=$_POST['name']; $sub=$_POST['subject']; $email=$_POST['email']; $phone=$_POST['phone'); $comment=$_POST['inquiry']; if(isset($_POST['submit'])) { $sql="INSERT INTO contact(name,subject,email,phone,comment) VALUES('$name'','$sub','$email','$phone'','$comment')"; $result=mysql_query($sql); if($result) { echo "<script type='text/javascript'>javascript:alert('message send.'); window.location='contact.php';</script>"; exit; } } mysql_close($con); ?> |
| | isset returns boolean, it gives you either 1or 0. | |
Tidak ada komentar:
Posting Komentar