PHP/HTM form works fine but needs two clicks

  Awestruck 19:58 06 Aug 2005

My form using htm form and php handler needs two clicks of submit button. On first click the php address appears in the I.E. address bar, on 2nd click the form is sent.

I can't see why this happens, any clues please?


  Forum Editor 23:11 06 Aug 2005

seeing the code. Presumably you've checked it thoroughly?

  Awestruck 10:53 07 Aug 2005

Dear Forum Editor
So sorry to have bothered you. I woke up this morning with the answer. I had used a php form handler which dynamically sets up the form. Two form setups = two clicks. Oh dear, it is a real handicap being daft.

Kind regards


  Forum Editor 12:01 07 Aug 2005

I'm glad it's fixed anyway.

  Awestruck 18:05 07 Aug 2005

Sorry to bother you again, I have now cured the double click problem, but I need advice on formatting PHP screen output.
I have searched the web and found nothing but date formatting. I need to know how to set margins, position of text, and text colour.
I want the dynamically written form in the appended feedback.php file to look the same as the form in the appended feedback.html file.
When an error is flagged, perhaps I should exit to the html form's display and also display the error message(s) but I do not know how that is done.
Thanks for your patience

<title>html Feedback Form</title>


<form action="feedback.php" method="post">
<b><font color="#008000" size="4">Please fill in the form and click the 'Send Form' button</font></b>
<p>   <font color="#008000"><b>Your Name:</b> <input type="text" name="username" size="30">
<p><font color="#008000"><b>Your Email address:</b> <input type="text" name="useraddr" size="30">
<p><font color="#008000"><br>
<textarea name="comments" cols="30" rows="5">
<p>    <input type="submit" name="sent" value="Send Form">   <input type="reset" value="Clear boxes and start again">



<!-- For PHP 5.0.0 final release. Could be used as a combined form creator and handler
if only I knew how to format the form's position and colour-->

<head><title>PHP Feedback Form</title></head>


$self = $_SERVER['PHP_SELF'];
$username = $_POST['username'];
$useraddr = $_POST['useraddr'];
$comments = $_POST['comments'];
$sent = $_POST['sent'];

#the HTML form that can be written dynamically
$form ="<form action=\"$self\" method=\"post\">";
$form.="Name:<input type=\"text\" name=\"username\"";
$form.=" size=\"30\" value=\"$username\" ><br/><br/>";
$form.="Email:<input type=\"text\" name=\"useraddr\"";
$form.=" size=\"30\" value=\"$useraddr\"><br/><br/>";
$form.="Comments:<textarea name=\"comments\" cols=\"30\" rows=\"5\">";
$form.="<input type=\"submit\" name=\"sent\" value=\"Send Form\">";

#set variable default value

#check username field is not blank
if( !$username )
{ $errmsg.="Enter your name...<br />"; $valid = false; }

#check email useraddr field is not blank
if( !$useraddr )
{ $errmsg .="Enter your email address...<br />"; $valid = false; }

#check comments field is not blank
if( !$comments )
{ $errmsg.="Enter your comments...<br />"; $valid = false; }

#check validity of email format
$useraddr = trim($useraddr);
#permitted patterns for name,domain and top-level domains
$_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+";
$_host = "([-0-9A-Z]+\.)+";
$_tlds = "([0-9A-Z]){2,4}$/i";
if( !preg_match( $_name."@".$_host .$_tlds,$useraddr ) )
$errmsg.="<H2>Email address has incorrect format!</H2><br />";

#if not valid write the error message/s and repeat the form
if($valid != true)
echo( $errmsg.$form );
#if the form is valid send the email
#recipient's email address
$to = "[email protected]";

#subject of the message
$re = "Feedback from $username";

#message from the feedback form
$msg = $comments;

#set the Content-type header for HTML mail
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;";
$headers .= "charset=\"iso-8859-1\"\r\n";

#set the From header
$headers .= "From: $useraddr \r\n";

#send the email now...
if(mail($to,$re,$msg, $headers))
{ echo("Your comments have been sent - thank you $username");}



This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

50 best online Adobe XD tutorials

iPad Pro 10.5in (2017) review

Comment connecter un MacBook à une TV ?