| | |
Help with PHP and checkboxes
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2005
Posts: 11
Reputation:
Solved Threads: 0
Hi,
I'll explain basically what I'm trying to do.
A person goes to my site to download. Before they can download they have to agree to the TOS (according to my lawyer this is best). So on the page (let's call it agree.php) I need several things:
1. textarea with the TOS. This is no problem. I know how to do that.
2. a checkbox stating I have read and agree to the TOS. No problem input type=checkbox.
3. Validation. I can do client-side no problem (using JS) but I'm after server side validation.
Can someone tell me how to do this with php or recommend a good resource? I don't know much PHP or this would probably be simple. Here was my best guess:
<?php
/* Get URL to "goto" from POST var */
$agr = $_POST["agree"];
if ($agree == checked){
header("Location: http://www.downloadurl.com/");
}
elseif ($url != checked){
header("Location: http://www.nodownloadurl.com");
}
?>
Also if possible I was hoping to simple have the PHP write in at the top of the page 'You must agree to TOS' if they tried to submit without checking the box. Is that possible? Solutions and resources are appreciated.
I tried using the above, but it instantly redirected instead of waiting for the form to be submitted. :lol:
Greg
I'll explain basically what I'm trying to do.
A person goes to my site to download. Before they can download they have to agree to the TOS (according to my lawyer this is best). So on the page (let's call it agree.php) I need several things:
1. textarea with the TOS. This is no problem. I know how to do that.
2. a checkbox stating I have read and agree to the TOS. No problem input type=checkbox.
3. Validation. I can do client-side no problem (using JS) but I'm after server side validation.
Can someone tell me how to do this with php or recommend a good resource? I don't know much PHP or this would probably be simple. Here was my best guess:
<?php
/* Get URL to "goto" from POST var */
$agr = $_POST["agree"];
if ($agree == checked){
header("Location: http://www.downloadurl.com/");
}
elseif ($url != checked){
header("Location: http://www.nodownloadurl.com");
}
?>
Also if possible I was hoping to simple have the PHP write in at the top of the page 'You must agree to TOS' if they tried to submit without checking the box. Is that possible? Solutions and resources are appreciated.
I tried using the above, but it instantly redirected instead of waiting for the form to be submitted. :lol:
Greg
![]() |
Similar Threads
- PHP Checkbox (PHP)
- Accessing HTML checkboxes with php and javascript (PHP)
- php coding for checkboxes (PHP)
- checkbox values calculation with PHP (PHP)
Other Threads in the PHP Forum
- Previous Thread: need help in C/PHP
- Next Thread: Community Pack - Forum/Blog
| Thread Tools | Search this Thread |
apache api array basic beginner binary broken cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation neutrality oop parsing paypal pdf php problem query question radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web xml youtube





