Amazon Web Service functional form - php

I have compleated the html and css of a website and I intend to host it on AWS. I have two forms on the site(html/css) and I need to make them functional. My php knowlege and database is very basic and I haven't use AWS before. How should I procead about making my froms functional? Is there any prebuild features in AWS that I could use for this purpuse? Perhaps a good tutorial I could fallow.. My forms are very simple and I'm only requesting a few input fields from visitors that I would need to have access to.
I will really apreciate any advice.
Here is my html:
<form
name="submitForm"
method="post"
id="submitMessageForm"
onsubmit="return(validate())"
action="./index.php?action=submitted"
class="form-style">
<label for="name">Name:</label>
<input
type="text"
id="nameFirst"
name="nameFirst"
placeholder="Enter Name"/>
<label for="email">Email:</label>
<input
type="text"
id="email"
name="email"
placeholder="Enter Email"/>
<label for="messageContent">Message:</label>
<textarea
id="messageContent"
name="messageContent"
rows="7"></textarea>
<br>
<input
style="padding: 6px !important;"
class="button"
type="submit"
id="submit"
name="SEND"/>
</form>

Related

Chrome auto-fill are filling the wrong text inputs

I am coding a php website. My issue is really on the profile page. The auto-fill is putting my email address where I have an input for the street address. Here is an image of what I mean.
<input type="text" name="txtstreetaddress" id="txtstreetaddress" placeholder="Street Address" tabindex="6" value="<?php echo $address ?>" style="font-family: 'Ubuntu';margin-top: -30px;font-size: 14px;height: 30px;width: 280px;" autocomplete="off" value="">
I also have the Form set to autocomplete="off"
You got to use autocomplete="false" instead of "off".
If this still does not work (what i don't expect) you can handle it by putting two fake-fields at the beginning of your form like the following ones:
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>
check my answer here.
https://stackoverflow.com/a/62943913/12332625
Use labels for the input fields. I think your problem is that you have 2 input fields on one line. <label for="email">Your email</label> etc. should fix your problem.
Like this:
<label for="txtstreetaddress">Street Address:</label> <input type="text" name="txtstreetaddress" id="txtstreetaddress" placeholder="Street Address" tabindex="6" value="<?php echo $address ?>" style="font-family: 'Ubuntu';margin-top: -30px;font-size: 14px;height: 30px;width: 280px;" autocomplete="off" value="">

inserting a premade email contact form into website

I have very little knowledge of php so I went ahead and used one from css-tricks email forms he set up for free use:http://css-tricks.com/nice-and-simple-contact-form/.
However I am not sure how to put it into the website without breaking the php code. I assume I can't simply just take the code that I want, which is
<div id="contact-area">
<form method="post" action="contactengine.php">
<label for="Name">Name:</label>
<input type="text" name="Name" id="Name" />
<label for="City">City:</label>
<input type="text" name="City" id="City" />
<label for="Email">Email:</label>
<input type="text" name="Email" id="Email" />
<label for="Message">Message:</label><br />
<textarea name="Message" rows="20" cols="20" id="Message"></textarea>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>
<div style="clear: both;"></div>
<p>Check out a version of this with SPAM protection.</p>
</div>
and put it into my html page. I tried using an iframe to link the html page into my html page for my website and it worked, but is this method ok?
Yes, you can just place that coding in your HTML page as long as all the webpage and css file's are linked correctly.(e.g. In the same folder as this page with the coding you have now.)
Using an i-frame for this is not a good idea as it can really mess up your pages and submitting your form.

Receive form data on email

How may I get data of this form to be received in an email?
<form class="pa">
<fieldset>
<label>Name <em>*</em></label>
<input type="text" placeholder="">
<label>Email <em>*</em></label>
<input type="text" placeholder="">
<label>Age <em>*</em></label>
<input type="text" placeholder="">
<label>Phone <em>*</em></label>
<input type="text" placeholder="">
<label>Zip Code <em>*</em></label>
<input type="text" placeholder="">
<a class="submit pa" href="#"><img src="wp-content/themes/child/img/submit.png"</a>
</fieldset>
</form>
You'll need a server-side script to accept the form data, and send an email with it. You can do this PHP and several other languages. Judging by your sample code you have WordPress, so you might look into the ContactForm plugin.
wrap your input's with something like
<form class="pa" action="yourscript.php" method="post">
.
.
<label for="name">Name <em>*</em></label>
<input type="text" placeholder="" id="name" name="name">
.
<input type="submit" value="Submit" />
<!-- remove the a tag because that won't submit your form data or use type="image" -->
<input type="image" src="wp-content/themes/child/img/submit.png" />
</form>
then use $_POST['name'] to retrieve the value
you have to add name='' to each inputs to have them sent to your script eg <input type="text" id="name" name="name"> and they have to be different otherwise they might get overridden.
also your labels will need the for= to be useable which uses the id of the input eg <label for="name">Name <em>*</em></label>

Usercheck.php Script Request

I am looking for a script to check my database to see if a username is already in use. I am new to PHP so talk to me like I am 10 (even though a ten year old can probably program better than me). I just want to check the database and return a true or false based on a variable that is entered in my form below. Also, I want to use an AJAX request to make this happen so I don't know if that matters. Also I am using SQL Buddy.
<p><form action="/signup/register.php" method="post">
<label for="first_name">First Name</label>
<input type="text" name="first_name" />
<label for="last_name">Last Name</label>
<input type="text" name="last_name" />
<label for="company">Company</label>
<input type="text" name="company" />
<label for="job_title">Job Title</label>
<input type="text" name="job_title" />
<label for="phone">Phone</label>
<input type="text" name="phone" />
<label for="email">Email</label>
<input type="text" name="email" />
<label for="username">Choose a Username</label>
<input type="text" name="username" />
<label for="password">Choose a Password</label>
<input type="text" name="password" />
<label for="confirm_password">Confirm Your Password</label>
<input type="text" name="confirm_password" />
<input type="submit" value="Get Started" />
</form>
This is one of the things php is good for.
Since you say you are beginner programmer I'm going to point you
to a basic tutorial on checking Databases with sql:
HP 101 (part 8): Databases and Other Animals - Part 1
This tutorial covers all you need:
A little SQL
MySQL connection
Integration with a form.
In general all the PHP 101 series is really good for beginners.
If you prefer a more detailed coverage of the topic then: PHP and MySQL Web Development (4th Edition) is the best beginners book. IMO

HTML contact form in PHP block

I'm relatively new to PHP so forgive me if this seems obvious. How would you integrate a block of HTML code like this:
<form action="form.php" method="post" enctype="multipart/form-data">
<label></label>
<input name="name" required="required" placeholder="Your Name">
<label></label>
<input name="email" type="email" required="required" placeholder="Your Email">
<label></label>
<input name="address" type="name" required="required" placeholder="Your Address">
<label></label>
<textarea name="message" required > Dear Mr. X, Please support us... </textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
into here:
if(empty($mpemail)){
echo "<h2>Send your MP our pre-written letter</h2>
<p>Unfortunately, your MP's email address is not listed in our database.</p>";
}
else {
echo "<h2>Send your MP our pre-written letter</h2>";
echo "<p>Please fill out the information required below:</p>";
**Insert Contact Form Here**
echo "<h2>Share this with your followers!</h2>";
echo 'Tweet ';
echo "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>";
}
Thanks in advance for your help.
So, one option is to echo it out line by line, as your PHP code sample is doing, or in one big block. You can also combine PHP and HTML in the same file by starting and stopping the PHP interpreter. Here's an example of that:
if (empty($mpemail))
{
echo "<h2>Send your MP our pre-written letter</h2>
<p>Unfortunately, your MP's email address is not listed in our database.</p>";
}
else
{
?>
<h2>Send your MP our pre-written letter</h2>
<p>Please fill out the information required below:</p>
<form action="form.php" method="post" enctype="multipart/form-data">
<label></label>
<input name="name" required="required" placeholder="Your Name">
<label></label>
<input name="email" type="email" required="required" placeholder="Your Email">
<label></label>
<input name="address" type="name" required="required" placeholder="Your Address">
<label></label>
<textarea name="message" required > Dear Mr. X, Please support us... </textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
<h2>Share this with your followers!</h2>
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<?php
}
In a professional production application, the "right way" to do it is to separate your HTML from your PHP by putting the logic of your application in a separate PHP file, and then putting your HTML in a "template" which you load and display from PHP. Here is a bit of info about getting started with template engines and Model View Controller patterns in an application. But, for what you're trying to do, the example above of starting and stopping the interpreter should work for you.

Categories