Reputation: 86
if condition is not working here. i've gone through the earlier solutions but i didn't find a right solution . i couldn't understand the reason . please help me out
<?php
require'core.inc.php';
require'connect.inc.php';
include 'header.php';
if(isset($_POST['submit'])) {
$query="INSERT INTO college (CollegeName) VALUES ('".$_POST['college']."')";
$result=mysql_query($query) or die(mysql_error());
header('Location:index.php');
}
?>
<form action="insert.php" method="POST">
<input type="text" name="college">
<input type="submit" value="submit" value="Submit">
</form>
<?php include'footer.php';?>
Upvotes: 0
Views: 8984
Reputation: 870
Also, this method is not the best practice for it doesn't work on Internet Explorer. At the time of writing these i had tried it on IE 8. I find most programmers using this method for one reason or another. My two coin cents would be to check if a POST method has been requested. Please see how you could approach it below.
if($_SERVER['REQUEST_METHOD'] == 'POST'){
//if a request has been made, do something. Example post or email your data
}
Upvotes: 2
Reputation: 30488
You have two value
here in <input>
, 1 at least should be name
. Also there is no <button>
, so remove the Submit</button>
.
<input type="submit" value="submit" value="Submit">Submit</button>
^^^^^ ^^^^^ ^^^^^^^^^^^^^^^
should be
<input type="submit" name="submit" value="Submit"/>
Upvotes: 11