php - How do I make an element appear after form submission? -
i have simple, working form , i'd make html element appear after form has been sent , page has reloaded.
what have far:
<?php $firstname = $_post['firstname']; $lastname = $_post['lastname']; $email = $_post['email']; $company = $_post['company']; $phone = $_post['phone']; $message = $_post['message']; $formcontent=" first name: $firstname \n last name: $lastname \n phone: $phone \n company: $company \n message: $message"; $recipient = "someone@example.com"; $subject = "client webform"; $mailheader = "from: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("error!"); $result= '<p>thanks!</p>' ?>
the form's action set same php file. reloads same page.
and below submit button have echo of result:
<?php echo $result; ?>
currently $result displayed on webpage loads, need appear when form sent , page reloads.
apologies, i'm beginner , simple.
give name submit button below
<input type="submit" name="btnsubmit" value="submit" />
or
<button type="submit" name="btnsubmit">submit </button>
then check button clicked , submitted form below
if( isset($_post["btnsubmit"]) ){ $result= '<p>thanks!</p>'; }
or can control other required fields 'email', 'name'.
dont use if($_server['request_method'] == 'post'){ }
because page can hold more 1 form , can't detect form submitted.
Comments
Post a Comment