Jump to content

Wierd problem


KenHorse

Recommended Posts

I'm trying to work out a problem with a suite of scripts and wrote a very simply "test" script to see if I could figure out what I'm doing wrong in another place. Here's my test one:

 

<?php

$id = 776; 


print '$id ' . "$id\n";   

if(isset($POST['cancel'])){
    print "Exiting";
	exit();
}

if(isset($_POST['submitted'])){
	print '$id ' . "$id";   
}

print "
   <input type=\"submit\" value=\"Save\" name=\"submitted\">
   <input type=\"submit\" value=\"Cancel\" name=\"cancel\">
";
?>

Normally $id is read in from a MySQL database and some of the above code appears in a script (as a pop up) referenced by another script. So I'm assigning $id in my test instead of reading it at the time the script is first run.

 

Anyway... the script loads fine in a browser with the first print statement properly showing "$id 776". Howver clicking either the Save or Cancel buttons do nothing at all. What am I doing wrong?


 

Edited by KenHorse
Link to comment
Share on other sites

Besides the $POST['cancel'] typo, the buttons have to be in a form.

$id = 776;


print '$id ' . "$id\n";

if(isset($POST['cancel'])){
print "Exiting";
exit();
}

if(isset($_POST['submitted'])){
print '$id ' . "$id";
}

print "
</pre>
<form method='\"post\"'>


</form>
<br>";<br

[edit] Oookay, indentation doesn't want to work for me.

Edited by requinix
Link to comment
Share on other sites

I added form to it, also you didn't have $_POST['cancel']

 

<?php

$id = 776;


print '$id ' . "$id\n";   

if(isset($_POST['cancel'])){
    print "Exiting";
    exit();
}

if(isset($_POST['submitted'])){
    print '$id ' . "$id";   
}

print "
   <form action=\"\" method=\"post\">
   <input type=\"submit\" value=\"Save\" name=\"submitted\">
   <input type=\"submit\" value=\"Cancel\" name=\"cancel\">
   </form>
";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.