help with my PHP code....?

  • Thread starter Thread starter angel_hugs86
  • Start date Start date
A

angel_hugs86

Guest
Do you abide by the Terms and Conditions of this site?

Please click a button

button: Agree
button: Disagree

when you press the button agree the text "Please click a button "

will be replaced by"Thanks for registering"


then if you press the button disagree the text "Please click a button "

will be replaced by"ok Thanks anyway "

+++++++++++++++++++++++++++++
my PHP code is

<form name=1>
<input type= "submit" name= "yes" value=" I Agree">
<input type= "submit" name="no" value= " I Disagree">
</form>

<?php
if ($_GET ['1']== "yes")
$response = print("Thanks for agreering to the terms and conditions... Welcome to the site");
elseif($_GET['1'] == "no")
$response = print("Oh that's too bad, but thanks just the same....");
else
$response = print ("Please click a button...");

?>
++++++++++++++++++++++

the problem is when i click those button it will not display anything...
it just remain as it is default which is the " Please press the button " statement

are all my codes ok?
or there is still lacking..
can somebody help me.
 
<?php
unset($response);

if ($_POST['yes']){
$response = print("Thanks for agreeing to....");
} else if($_POST['no']){
$response = print("Oh that's too bad...");
} else{
$response = print ("Please click a button...");
}
?>

<?
if(!isset($response)){
?>
<form name="formyes" method="post" action="">
<input type="submit" name= "yes" value=" I Agree">
</form>
<form name="formno" method="post" action="">
<input type="submit" name="no" value= " I Disagree">
</form>
<?
else echo $response;
?>

the method is post because its just that much more secure, also the action is "" if the php resides on the same page. Otherwise, replace the action with the path of the PHP file that processes the forms. I chose to use two forms because it is just that much better. Also, the if($_POST) references the submit buttons...because thats what the PHP first sees of the form when you submit a form: the request to submit. This page submits on 1 PHP page and processes the form as well as displays the response once it has something in it. :)

If you need any further assistance, please email me at [email protected]
 
You have to put an action to your form that will interpret your inputs, something like:

<form action="link_to_action.php" method="POST">

then from that file it will interpret the user input. You can redirect them to another page that says "thank you" page or "error page" depends on user input.
 
You have to put an action to your form that will interpret your inputs, something like:

<form action="link_to_action.php" method="POST">

then from that file it will interpret the user input. You can redirect them to another page that says "thank you" page or "error page" depends on user input.
 
Back
Top