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
Related
I am coding up a website and have added a contact form. When I try and test out the form by submitting, it will just open up the email client for me to send it through the email client (it's opening up my apple mail automatically). I want the user to be able to submit the form without the email client on their device opening up, then I want to receive an email saying that a customer has sent me a message from my website. how do I do this? what am I missing or doing wrong?
<form method="post" action="myemailhere#gmail.com" action="action_page.php">
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Your name...">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Your last name...">
<label for="country">e-mail</label>
<input type="text" id="lname" name="lastname" placeholder="Your e-mail address...">
<label for="subject">Subject</label>
<textarea id="subject" name="subject" placeholder="Write something..." style="height:200px"></textarea>
<input type="submit" value="Submit">
</form>
</div>
<form method="post" action="nuramelodyhill#gmail.com" >
<input type="submit" value="Send Email" />
</form>
Just Remove the action="myemailhere#gmail.com" - it will be work.
in PHP you can simply send email with
mail($to,$subject,$message);
Your code should be like this:
<form method="post" action="action_page.php">
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Your name...">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Your last name...">
<label for="country">e-mail</label>
<input type="text" id="email" name="email" placeholder="Your e-mail address...">
<label for="subject">Subject</label>
<textarea id="subject" name="subject" placeholder="Write something..." style="height:200px"></textarea>
<input type="submit" value="Submit">
</form>
</div>
action_page.php
$subject=$_POST['subject'];
$message="First Name:".$_POST['firstname']."\n Last Name:".$_POST['lastname']." Email:".$_POST['email']."\n Subject:".$_POST['subject'];
mail($to,$subject,$message);
And also you using 2 forms here. If you want to use multiple forms on the same page, use JavaScript to fire the event.
I purchased subscription addon from here, but its not working I have successfully installed it and its showing in my admin panel but when i write below code its not showing anything to me on my page.
{exp:subs:subscribe register_member="yes" plan="{segment_3}" payment_method="stripe" return="/account/subscription/%SUBS_HASH%"}
<h1>Subscribe to: {subs:plan:label}</h1>
<p>
Every <strong>{subs:plan:recurring_interval_count} {subs:plan:recurring_interval}</strong> {subs:plan:recurring_amount} {subs:plan:currency}
</p>
<hr>
{if subs:total_errors}
<ul class="errors">
{subs:form_errors}
<li>{subs:error}</li>
{/subs:form_errors}
</ul>
{/if}
<h3>Credit Card</h3>
<label>Credit Card Number</label>
<input name="card_number" type="text" value="{subs:card_number}">
<label>Name on card</label>
<input name="card_name" type="text" value="{subs:card_name}">
<label>Expires</label>
<select name="card_exp_month">{subs:month_options}</select>
<select name="card_exp_year">{subs:year_options}</select>
<label>Security Code</label>
<input name="card_cvc" type="text" value="{subs:card_cvc}" size="5">
<button type="submit">Subscribe</button>
{/exp:subs:subscribe}
I used their example code you can find it here.
please help me thanks in advance.
Your page is showing blank because page is not getting {segment_3} i.e. plan i hope you have not create any plan or if created then you have not passed them as {segment_3}. To test this thing use below code it will be helpful for you.
{exp:subs:subscribe register_member="yes" plan="gold" payment_method="stripe" return="/account/"}
<h1>Subscribe to: {subs:plan:label}</h1>
<p>
Every <strong>{subs:plan:recurring_interval_count} {subs:plan:recurring_interval}</strong> {subs:plan:recurring_amount} {subs:plan:currency}
</p>
<hr>
{if subs:total_errors}
<ul class="errors">
{subs:form_errors}
<li>{subs:error}</li>
{/subs:form_errors}
</ul>
{/if}
{if logged_out}
<h3>User Account</h3>
<label>Username</label>
<input type="text" name="username" value="">
<label>Email</label>
<input type="text" name="email" value="">
<label>Password</label>
<input type="password" name="password" value="">
<label>Password Confirm</label>
<input type="password" name="password_confirm" value="">
{/if}
<h3>Credit Card</h3>
<label>Credit Card Number</label>
<input name="card_number" type="text" value="{subs:card_number}">
<label>Name on card</label>
<input name="card_name" type="text" value="{subs:card_name}">
<label>Expires</label>
<select name="card_exp_month">{subs:month_options}</select>
<select name="card_exp_year">{subs:year_options}</select>
<label>Security Code</label>
<input name="card_cvc" type="text" value="{subs:card_cvc}" size="5">
<button type="submit">Subscribe</button>
{/exp:subs:subscribe}
make a plan named gold or abc whatever you want must put the same name at plan="plan_name" at the first line you can see it and remember for Visa cards it requires some more fields you may get fields error for this you have to use that fields you can find those fields on devdemon website.
enjoy !!!
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>
Yes, forms of this question are asked all the time. Due to the infinite possible ways that one can construct a form/php pair, my question still is different. (and much simpler)
I have:
<html>
<body>
<form id="request-inspecton" action="test_form_processor.php" method="POST">
<label class="text-label" for="FirstName">*first name:</label>
<input class="text-input" type="text" name="FirstName" id="FirstName" required="required" placeholder="First Name">
<label class="text-label" for="LastName">*last name:</label>
<input class="text-input" type="text" name="LastName" id="LastName" required="required" placeholder="Last Name">
<input class="button-input" type="submit" value="send" id="buttonSend" name="submitForm" placeholder="Submit form" value="POST">
</form>
</body>
</html>
and:
<?php
var_dump($_POST);
print $_POST["FirstName"];
?>
But all I get is:
array(0) { }
Golly, I just can't figure out what is wrong!\
Incidentally, example currently at:
http://checkitouthomeinspection.com/test_form.html
Strangely enough, it now works in both FF and Chrome. Beats me what the problem was. Thanks for the help. Case closed.
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>