Log in

View Full Version : !isset $_POST submit



insanemonkey
04-21-2008, 02:13 PM
hi I am trying to make something to do as insert into my database...
i have done this before and i dunno why its not working.. plz help.



<?PHP
include('dbconnect.php');

if (!isset($_POST['submit'])) {
?>
<form action="insertdl.php" method="post">
url: <input name="url" type="text">
<input type="submit" value="submit" name="submit">
</form>

<?PHP
} else {


$url = $_POST['url'];
$count = 1;

mysql_query("INSERT INTO downloads
(link, count) VALUES('$url', '$count' ) ")
or die(mysql_error());

echo' "data inserted";
}

?>


plz help

city_coder
04-21-2008, 02:22 PM
I duno i dont see why it shouldnt be working, but you have got an extra quote where you say echo ' "data inserted"; also shouldnt you do a check to make sure that the query was a result, i duno thats what i do, especially when im inserting stuff.

anyway try it the other way round, or try checking for $_POST['url'] or try getting it and changing post to get in the form.

besides that which you have probably done, i dont see why

insanemonkey
04-21-2008, 02:33 PM
i did check before doing the form submit to see if it did insert into the database and it doesn't..
not there is something wrong with the submit its not recongizing the the forum submit post, i dunno why its not....

with the echo, it will still work i just messed up when posting the code here...

Master_script_maker
04-21-2008, 07:42 PM
try this:

<?PHP
include('dbconnect.php');

if (!isset($_POST['url'])) {
?>
<form action="insertdl.php" method="post">
url: <input name="url" type="text">
<input type="submit" value="submit" name="submit">
</form>

<?PHP
} else {


$url = $_POST['url'];
$count = 1;

mysql_query("INSERT INTO downloads
(link, count) VALUES('$url', '$count' ) ")
or die(mysql_error());

echo "data inserted";
}

?>

insanemonkey
04-22-2008, 02:59 PM
ok i got it.. i dont know what the problem was but it all of sudden started working 10minutes later... i think my cache maybe or cookies... i dunno.. but thanks guys