php - How to add preformatted text on text fields by clicking a button from another page
newbie here. Using php. So I have a button. When clicked will go to a contact page that I have already done. But I need to automatically put text into a text field for the message. All one has to do is click send as it is already formatted for them. How do I make the button automatically add text into the textfield(s)? I now realize it probably needs an onlick event or anything similar on the button that will post values on some text fields on the contact page being called. I hope I have given a better description of my problem. thanks guys.
Say this is my button:
<input type="submit" name="button" id="button" value="Submit" />
on submit will go to contact page and fill in the values of some textfields I need preformatted.
here's my sample mailer script.
<?php
//print_r($_POST);
if(isset($_POST['_save'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$message = $_POST['message'];
$subject = $_POST['subject'];
if (empty($name) || empty($email) || empty($subject) || empty($message)) {
if (empty($name))
$error['name'] = "Please enter your Full Name";
if (empty($email))
$error['email'] = "Please enter a valid Email Address";
if (empty($company))
$error['company'] = "Please enter Your Company Name";
if (empty($subject))
$error['subject'] = "Please Write a Subject";
}
else { //if not empty
$headers="From: {$email}\r\nReply-To: {$email}"; //create headers for email
$content="Name: ".$name."\r\n\r\nCompany: ".$company."\r\n\r\nSubject: ".$subject."\r\n\r\nMessage: ".$message;
mail('[email protected]',$subject,$content,$headers); //mail the message;
$success = "Thank you! You're email has been sent.";
#done;
}
}
?>
Answer
Solution:
I am not sure but if i understand correctly your requirement. then probably you want this.
If i am right and above scenario is correct then you can do like this:
$_request
can get both post or get data.thanks
Answer
Solution:
on your previous page (eg. the input form for mail) use this;
or simply,
Answer
Solution:
As I read your question, I assume you have this flow in mind:
Probably a button,
or
that will redirect to contacts.php, where
<input>
fields are presentNow (just an assumption) that you want to have this fields default values when loaded, if it is, then all you have to do is set
<input value="" />
You can set dynamic values for this, but I'm not sure where you want those values to come from.
EDIT:
I created a demo of populating the fields by an onClick event in button.