help needed
Posted: Wed Dec 31, 2003 1:15 am
I want to do a form which makes the user click "i agree" before the submit button can be clicked... I got this code from the net and tried but there seems to be something wrong... It does not goes to my If($_POST['submit'])... Please help to see what is wrong with it... Thanks
This is the code :
[Edit: Added PHP tags --JAM]
This is the code :
Code: Select all
<?php
if (isset($_POST['submit']))
{
require_once ('../mysql_connect.php'); // Connect to the database.
$query = "UPDATE song SET status='Being Published', datecontract='$today' WHERE refnum={$row['refnum']}";
$result = mysql_query ($query);
if($result) {
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "index.php");
exit();
}
else {
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "admin.html");
}
mysql_close();
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="agreeform" >
/* text */
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br>
<input type="submit" name="submit" value="Submit!" disabled>
</form>
<script>
//change two names below to your form's names
document.forms.agreeform.agreecheck.checked=false
</script>
<script>
//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
</script>