php - if isset($_POST issue -
i have 1 instance of user on php site can login, , i'm trying make second administrators can post announcements.
my login works beautifully, reason can't announcement submission work. despite input fields being named appropriately, field being seen "not set" when type in title , announcement on form. here code:
form:
<form action="announce.php"> <input type="text" name="title" /> <textarea name="announce" cols="20" rows="2" ></textarea> <input type="submit" name="submit" value="announce" /> </form>
here php:
include_once 'creds.php'; $con=mysqli_connect("$db_hostname","$db_username","$db_password","$db_database"); if (isset($_post['title'])) { $title = $_post['title']; $announce = $_post['announce']; $query = "insert announcements (labname, name, author, announce) values ($lab, $title, $username, $announce)"; $insert = mysqli_query($con, $query); mysqli_close($con); echo "added successfully";} else { echo "something went wrong"; }
my other form seems work 1 doesn't... syntax wrong somewhere?
your form submitting request, not post.
change line:
<form action="announce.php">
to this:
<form action="announce.php" method="post">
edit: should refresh page before posting. credit noobie-php getting right in comment 30 mins before posted this!
Comments
Post a Comment