-
submit button wont post
hey all,
as some of you may know, i have been having a ot of difficulties getting a form to work. i have now found the problem. the $HTTP_POST_VARS wont recognise that the submit button has a value. the following WONT work.
PHP Code:
<?
if(isset($HTTP_POST_VARS['submit'])) {
mail('[email protected]',$_REQUEST['subject'],$_REQUEST['message'] . '\n\nFrom,\n' . $_REQUEST['from_name'],'From: ' . $_REQUEST['from_email']);
echo "<b><center>Mail sent!</center></b><br>\n<a href=\"index.php\">Return to home</a><br>\n";
} else {
?>
<center><b>Email |DJ| P@CkMaN</b></center>
<form method="post" action="contact.php?action=webmaster">
Your name: <input type="text" name="from_name" size="35"><br>
Your email: <input type="text" name="from_email" size="35"><br>
Subject: <input type="text" name="subject" size="39"><br>
Message:<br>
<textarea rows="15" cols="38" name="message"></textarea><br>
<input type="image" src="../images/buttons/submit.gif" value="Submit" alt="Submit!" name="submit">
<?
}
?>
but if i check that the user typed something in message like this script
PHP Code:
<?
if(isset($HTTP_POST_VARS['message'])) {
mail('[email protected]',$_REQUEST['subject'],$_REQUEST['message'] . '\n\nFrom,\n' . $_REQUEST['from_name'],'From: ' . $_REQUEST['from_email']);
echo "<b><center>Mail sent!</center></b><br>\n<a href=\"index.php\">Return to home</a><br>\n";
} else {
?>
<center><b>Email |DJ| P@CkMaN</b></center>
<form method="post" action="contact.php?action=webmaster">
Your name: <input type="text" name="from_name" size="35"><br>
Your email: <input type="text" name="from_email" size="35"><br>
Subject: <input type="text" name="subject" size="39"><br>
Message:<br>
<textarea rows="15" cols="38" name="message"></textarea><br>
<input type="image" src="../images/buttons/submit.gif" value="Submit" alt="Submit!" name="submit">
<?
}
?>
it all works great?? :confused:
could someone please tell me whats going on and if theres a way that i can make it work with $HTTP_POST_VARS['submit']??
thanks heaps :)
-
try adding onclick="document.submit();"
to the image submit button.
<input type="image" src="../images/buttons/submit.gif" alt="Submit!" name="submit" onclick="document.submit();">
-
cant $REQUEST be used instead of $HTTP_POST_VARS :confused:
-
-
I think I found the problem, it does not seem to work when the submit button is an image :confused:
edit: I am sleepy and wrote a stupid answer :)
-
Ok I am in a daze, phpman you already figured it out, but the thing you wrote does not work for me.
-
try it a couple of ways.
<input type="image" src="../images/buttons/submit.gif" alt="Submit!" name="submit" onclick="submit();">
<input type="image" src="../images/buttons/submit.gif" alt="Submit!" name="submit" onclick="this.document.submit();">