I was hoping someone could let me know the php code to send the contents of this form through to my email.
Thanks!
I really have absolutely no idea when it comes to php so any help that you could provide would be very much appreciated!
Get in touch to discuss your project!
<input id="af-showreq" class="af-show-input" type="checkbox" name="showreq" />
<form class="af-form" id="af-form" novalidate>
<div class="af-outer">
<div class="af-inner">
<label for="input-title">Title</label>
<input type="text" name="title" id="input-title">
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-name">Name</label>
<input type="text" name="fullname" id="input-name" required>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-email">Email address</label>
<input type="email" name="email_address" id="input-email" required>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-country">Company</label>
<input type="email" name="country" id="input-country" required>
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-phone">Phone Number</label>
<input type="email" name="phonenumber" id="input-phone">
</div>
</div>
<input type="submit" value="Send it over!" />
</form>
</section>
</div>
</div>
first of all we want to turn the form into a post request. So when someone hits the submit button it will post the form data to your server. You can do this by changing your form tag to have a action (the page on your site you want to post back to") and method="POST".
<form class="af-form" action="" id="af-form" method="POST">
For more information on that look here.
http://www.w3schools.com/html/html_forms.asp
For post to work you need to make sure all your tags that you want to send over have a name tag. Currently your submit button doesn't change it to:
<input type="submit" name ="submit" value="Send it over!" />
Next on the page the post data gets sent to we want to make sure that we have post data. In php all post data is stored in a super variable called POST. So we can check if there is data in here. If there is then we can continue into making the email
if(isset($_POST['submit']){
//the rest of the code should be done in here
//as we only want to send the email if we have made a post request
}
Finally we can now take this information to send you an email
we can get input information by doing the following
$example = $_POST['email_address']
example will now have the information that people put in the email_address input box
sending an email in php is done with the mail() function. An example of this can be seen below
mail("whoto#email.com", "I am a subject", "I am the content of the email);
for more information on the mail function look at http://php.net/manual/en/function.mail.php
Related
I created a contact-form with username, email and a message.
Here is my code;
<form action="thanks.php" method="post">
<div>
<label for="nom">Nom :</label>
<input type="text" id="nom" name="user_name">
</div>
<div>
<label for="courriel">Courriel :</label>
<input type="email" id="courriel" name="user_email">
</div>
<div>
<label for="phone">Numéro de téléphone</label>
<input type="text" id="phone" name="phone_number">
</div>
<div>
<label for="message">Message :</label>
<textarea id="message" name="user_message"></textarea>
</div>
<div class="button">
<button type="submit">Envoyer votre message</button>
</div>
</form>
and I am looking for a solution after submitted this form, to make show a message with username, email and user's message.
something like;
"hi {username}, thank you for your message. we'll contact you by your {email} after reviewed your message"
I would like to know how I can make a new php page to show these details.
You would show the message on the page that processes your form request.
So if you form goes to processForm.php then when processForm.php is done processing the form it can then return whatever HTML you want it with access to the form values passed to it.
This is not really ideal and is generally handled via the page JS/HTML but if you have specific limits that require this then that is how you do it.
As for a specific example there are many on google for "php form processing"
I am making a registration form and have made some simple php to process the email as a test:
Hello <?php echo $_POST["email"]; ?>
I am using the post method, and although the atom editor was displaying the Hello, it doesn't display the email.
And in case anyone needs it, here is the html I am using:
<form action="welcome.php" method="post">
<div class="container">
<h1>Register</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw"
required>
<label for="psw-repeat"><b>Repeat Password</b></label>
<input type="password" placeholder="Repeat Password" name="psw-
repeat"
required>
<hr>
<p>By creating an account you agree to our <a href="#">Terms &
Privacy</a>.</p>
<button type="submit" class="registerbtn">Register</button>
</div>
<div class="container signin">
<p>Already have an account? Sign in.</p>
</div>
</form>
this code works fine, please make sure you echoing Hello <?php echo $_POST["email"]; ?> in welcome.php
if yes make sure you have php installed.
There is no error. If you place the php code provided in above in welcome.php, and you fill the form, email is displayed properly after Hello. There migh
here is my html
<form name="station" method="post" action="/stations/new" role="form">
<div class="form-group">
<label class="control-label required" for="station_name">Name</label>
<input type="text" id="station_name" name="station[name]" required="required" maxlength="255" class="form-control" >
</div>
<div class="form-group">
<div class="checkbox">
<label for="station_active">
<input type="checkbox" id="station_active" name="station[active]" value="1" />Active</label>
</div>
</div>
<div class="form-group">
<button type="submit" id="station_submit" name="station[submit]" class="btn btn-primary">Ajouter</button>
</div>
<input type="hidden" id="station__token" name="station[_token]" class="form-control" value="aze123aze" >
</form>
i want to get my form using the crawler. I tried the selectButton method like this
$form = $crawler->selectButton('station[submit]')->form(array());
but i get the error : InvalidArgumentException: The current node list is empty.
what is the problem ?
Unfortunately I have no enough rating to just write a comment instead of put it in the answer.
So, could you please show how are you getting $crawler? Problem might be:
$crawler not point to DOM which contains this form
this form appears on page after some java script actions(Ajax for example), but not sure that this is your case.
The selectButton method accept the value The button text. So Try with:
$form = $crawler->selectButton('Ajouter')->form(array());
Hope this help
after many days of trying to get a previously working php form converted to submitting the variables inside a new div I realized that I'm missing something. Other posts show javascript, but Iv'e never used that before and don't understand the need. The new page draws correctly, but the php variables are not being received on the destination page.
HTML for the submit,
<form action="entrance2.php">
<div class="medium-12 columns m-b20"><h4 class="heading">Existing users log-in here :-</h4></div>
</div>
<div class="row">
<div class="user medium-12 columns text-center m-b15"><img src="images/user-img.png" alt=""/></div>
</div>
<div class="row">
<div class="medium-10 columns medium-offset-1"><label for="User Name"></label>
<input id="OwnerEmaili" type="text" placeholder="User Name" name="UserName"></div>
</div>
<div class="row">
<div class="medium-10 columns medium-offset-1"><label for="Password"></label>
<input id="OwnerPasswordi" type="password" placeholder="Password" name="Password"></div>
</div>
<div class="row">
<div class="medium-12 columns text-center"><button class="grd-button">Log In</button></div>
<input type="submit" id="save" name="save" value = "Submit"/>//simple submit for testing
<div class="grd-button1" onClick="document.forms['submit-form'].submit();"></div>
</form></div>
</div>
</div>
Receiving page,
<?php
$p_OwnerEmaili=$_POST["OwnerEmaili"];
$p_OwnerPasswordi=$_POST["OwnerPasswordi"];
echo "$p_OwnerEmaili;$p_OwnerPasswordi";
Only shows the ;.
Is javascript required to submit from inside a div?
You're accessing the wrong items.
You'll need to set your forms input name attributes to this if you want to access them the way you currently have in your php script:
<input id="OwnerEmaili" type="text" placeholder="User Name" name="OwnerEmaili">
And
<input id="OwnerPasswordi" type="password" placeholder="Password" name="OwnerPasswordi">
That will allow you to access them as you do in your PHP script.
You can always check what values have been sent to your php script by using var_dump() or print_r().
<?php print_r($_POST); ?>
Would've shown you that you had UserName & Password set instead of what you wanted.
As Ghost pointed out in the comments, your form will always send user input via GET if you dont specify a method in it. So set this in your form tag:
<form action="entrance2.php" method="post">
I'm a newbie programmer trying to utilize Twitter Bootstrap to build out a concept. I'm using PHP and assigning actions within HTML tags to POST data and essentially take a user through the navigation. This has been pretty straightforward when using forms: i.e. here is a snippet that does work. For example, for this snippet of HTML:
<form action="?viewnotes" method="post">
<input type="hidden" name="id" value="<?php htmlout($note['id']); ?>">
</form>
It successfully triggers the following if statement in my index.php:
if (isset($_GET['viewnotes']))
However, I'm trying to do the same thing in my registration page, using a Twitter Bootstrap class for buttons. Here is the HTML:
<a class="btn btn-primary btn-large" action="?register">Sign Up Free!»</a></p>
The PHP code is:
if (isset($_GET['register']))
{
include 'register.html.php';
}
Clicking on the Sign Up button is not invoking the PHP code. If I hard code the URL it works, but then I have a similar issue on the register.html.php page. HTML on the register page has:
<form class="form-horizontal" action="?storeuser" method="post">
<fieldset>
<legend>It's quick and easy...</legend>
<div class="control-group">
<label class="control-label">First Name</label>
<div class="controls">
<input type="text" name="fname" class="input-xlarge" id="fname">
</div>
</div>
<div class="control-group">
<label class="control-label" name="lname">Last Name</label>
<div class="controls">
<input type="text" name="lname" class="input-xlarge" id="lname">
</div>
</div>
<div class="control-group">
<label class="control-label" name="email">Email Address</label>
<div class="controls">
<input type="text" name="email" class="input-xlarge" id="email">
</div>
</div>
<div class="control-group">
<label class="control-label" name="password">Password</label>
<div class="controls">
<input type="password" name="password" class="input-xlarge" id="password">
</div>
</div>
</fieldset>
<button type="submit" name="action" class="btn btn-primary btn-large">Complete Registration</button>
</form>
However, when clicking on the button, the index file does not trigger the following, which would store the fields into the DB.
if (isset($_GET['storeuser']))
If I hardcode the URL to register.html.php, then the resulting URL looks like localhost/register.html.php?storeuser instead of localhost/?storeuser. I'm not sure if that's affecting the behavior here.
Thank you for the help!
I think you're approaching this the wrong way, and it's not Twitter Bootstrap's fault.
Usually, you'd use POST, not GET, to handle user registrations. Your form would look like this:
<form action="register.php" method="post">
<!-- your form -->
<fieldset>
<input type="submit" name="register" value="Register" class="btn btn-primary" />
</fieldset>
</form>
You can then build register.php as follows:
<?php
if (isset($_POST['register'])) {
// handle user registration
}
// display form
?>
This will display the form when the user visits register.php, but will try and process the user registration first if the form's been POSTed.
try passing a value with your GET variable
<form action="?viewnotes=1" method="post">