I created the following HTML and PHP documents. When I fill in the information and click submit, I don't receive any errors, but I get a blank page and also don't receive an email with the form information. I'm fairly new at this, but could use the help on why I'm not getting the email and how to get rid of the blank page. Thank you.
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<div id="title">
<div id="titlecontact">
<h1>Excelerate Growth, LLC</h1>
<h4><em>Consulting to Help Small Businesses Excel</em></h4>
</div>
</div>
<header id="header">
<nav class="links" style="--items: 5;">
Home
About
Services
Results
Contact
<span class="line"></span>
</nav>
</header>
<?=$thankYou ?>
<form class="form" action="contact2.php" method="POST">
<h1>CONTACT US</h1>
<p class="name">Name</p><input class="nametext" type="text" name="sender" />
<p class="email">Email</p><input class="emailtext" type="text" name="senderEmail" />
<p class="phone">Phone</p><input class="phonetext" type="tel" name="senderPhone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required />
<br />
<br />
<p class="interest">Interest</p>
<select class="package" name="type" size="1">
<option value="update">Free Consultation</option>
<option value="change">Growth Management</option>
<option value="addition">Customer Service</option>
<option value="new">Process Management</option>
</select>
<br />
<br />
<p class="message">Share More About Your Business</p><textarea class="text" name="message" rows="6" cols="25"></textarea><br /><br />
<input class="submit" type="submit" value="Send"><input class="reset" type="reset" value="Clear">
</form>
<div id="social">
<img class="linkedin" src="linkedin.png">
<img class="email2" src="email.png">
<img class="facebook" src="facebook.png">
<br/>
<br/>
</div>
<br/>
<br/>
<?php
if($_POST["submit"]) {
$recipient="jscotty78#gmail.com";
$subject="Form to email message";
$sender=$_POST["sender"];
$senderEmail=$_POST["senderEmail"];
$senderPhone=$_POST["senderPhone"];
$type=$_POST["type"];
$message=$_POST["message"];
$mailBody="Name: $sender\nEmail: $senderEmail\nPhone: $senderPhone\nType: $type\n$message";
mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
$thankYou="<p>Thank you! Your message has been sent.</p>";
}
?>
Try This Code Below with name="submit"
<form class="form" action="contact2.php" method="POST">
<h1>CONTACT US</h1>
<p class="name">Name</p><input class="nametext" type="text" name="sender" />
<p class="email">Email</p><input class="emailtext" type="text" name="senderEmail" />
<p class="phone">Phone</p><input class="phonetext" type="tel" name="senderPhone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required />
<br />
<br />
<p class="interest">Interest</p>
<select class="package" name="type" size="1">
<option value="update">Free Consultation</option>
<option value="change">Growth Management</option>
<option value="addition">Customer Service</option>
<option value="new">Process Management</option>
</select>
<br />
<br />
<p class="message">Share More About Your Business</p><textarea class="text" name="message" rows="6" cols="25"></textarea><br /><br />
<input class="submit" type="submit" name="submit" value="Send"><input class="reset" type="reset" value="Clear">
</form>
POST form data is sent using name => value. Here:
<form class="form" action="contact2.php" method="POST">
<h1>CONTACT US</h1>
<p class="name">Name</p><input class="nametext" type="text" name="sender" />
<p class="email">Email</p><input class="emailtext" type="text" name="senderEmail" />
<p class="phone">Phone</p><input class="phonetext" type="tel" name="senderPhone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required />
<br />
<br />
<p class="interest">Interest</p>
<select class="package" name="type" size="1">
<option value="update">Free Consultation</option>
<option value="change">Growth Management</option>
<option value="addition">Customer Service</option>
<option value="new">Process Management</option>
</select>
<br />
<br />
<p class="message">Share More About Your Business</p><textarea class="text" name="message" rows="6" cols="25"></textarea><br /><br />
<input class="submit" type="submit" value="Send"><input class="reset" type="reset" value="Clear">
</form>
you have no input with name="submit". This is why $_POST['submit'] is equal to "", which is considered false in PHP. So mail() is not running.
Instead, try this:
<form class="form" action="contact2.php" method="POST">
<h1>CONTACT US</h1>
<p class="name">Name</p><input class="nametext" type="text" name="sender" />
<p class="email">Email</p><input class="emailtext" type="text" name="senderEmail" />
<p class="phone">Phone</p><input class="phonetext" type="tel" name="senderPhone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required />
<br />
<br />
<p class="interest">Interest</p>
<select class="package" name="type" size="1">
<option value="update">Free Consultation</option>
<option value="change">Growth Management</option>
<option value="addition">Customer Service</option>
<option value="new">Process Management</option>
</select>
<br />
<br />
<p class="message">Share More About Your Business</p><textarea class="text" name="message" rows="6" cols="25"></textarea><br /><br />
<input class="submit" type="submit" value="Send"><input class="reset" type="reset" value="Clear">
<input type="hidden" name="submit" value="a" />
</form>
Notice name="submit". This gets sent along with the form data.
I have 3 forms in an accordion, one for personal details, billing info and delivery info. I want to autofill the form in the delivery info section if the 'yes' radio button is selected when being asked if their billing and delivery info are the same.
I've looked on the web and can't seem to find anything on filling in a form in an accordion or on the same page.
Here is the HTML:
Details
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection details">
<form id="detailsform">
<label for="firstname">First Name*</label>
<input type="text" name="forename" />
<label for="lastname">Last Name*</label>
<input type="text" name="surname" />
<label for="email">Email*</label>
<input type="email" name="email" />
<label for="contactnumber">Contact Number*</label>
<input type="text" name="contactnumber"/>
<p class="marketingtext">Do you wish to be contacted by Interski with future promotions?</p>
<label>
<input type="radio" name="marketing" value="yes"/>Yes
</label>
<label>
<input type="radio" name="marketing" value="no"/>No
</label>
<div class="confirmdetailsbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
</form>
</div>
<h3>billing address</h3>
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection billing">
<form id="billingform">
<label for="firstaddress">1st line of Address*</label>
<input type="text" name="firstaddress"/>
<label for="secondaddress">2nd line of Address</label>
<input type="text" name="secondaddress"/>
<label for="town">Town*</label>
<input type="text" name="town" />
<label for="postcode">Postcode*</label>
<input type="text" name="postcode" />
<label for="country">Country*</label>
<select name="country">
<option></option>
</select>
<p class="billingtext">Is your delivery address the same as your billing address?</p>
<label>
<input type="radio" id="deliveryyes" name="deliveryradio" value="yes"/>Yes
</label>
<label>
<input type="radio" id="deliveryno" name="deliveryradio" value="no"/>No
</label>
<div class="confirmbillingbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
</form>
</div>
<h3>Delivery Address</h3>
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection delivery">
<form id="deliveryform">
<label for="firstaddress">1st line of Address*</label>
<input type="text" name="delfirstaddress" required/>
<label for="secondaddress">2nd line of Address</label>
<input type="text" name="delsecondaddress"/>
<label for="town">Town*</label>
<input type="text" name="deltown" />
<label for="postcode">Postcode*</label>
<input type="text" name="delpostcode" />
<label for="country">Country*</label>
<select name="delcountry">
<option></option>
</select>
<div class="confirmdeliverybtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
<div id="confirmbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_200x38_proceed_to_payment.png">
</div>
This is in complete assumption that as you mentioned its accordion,your page is not refreshed.
You can simply add an event listener on your Radio button to access the required fields and then use them to show wherever required.
Also give proper id's to your input fields
You can do it like this;
$("#deliveryyes").on('click',function(){
var firstaddress = $("#firstaddress").val();
...
// Use those values to populate other fields like
$("#delfirstaddress").val(firstaddress );
...
});
This way you can achieve it.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have created one HTML form and i have written php script also to connect to database. If i enter data in form and hit UPDATE button in form, its showing error like below,
<form action="process.php" method="Post"/>
<style>
p{
float:left;
}
</style>
<fieldset>
<legend align="center"><FONT color=default>Enter information Of SO's</legend>
<p align="center">
<label for="SO_ID"><FONT color=white>SO_ID</label>
<br/>
<input type="varchar" id="SO_ID" name="SO_ID"required/>
</p>
<p align="center">
<label for="No.of_samples"><FONT color=white>No.of samples</label>
<br/>
<input type="int" id="No.of_samples" name="No.of_samples"required/>
</p>
<p align="center">
<label for="Sample name"><FONT color=white>Sample name</label>
<br />
<input type="varchar" id="Sample name" name="Sample name"required/>
</p>
<p align="center">
<label for="Client name"><FONT color=white>Client name</label>
<br />
<input type="text" id="Client name" name="Client name"required/>
</p>
<p align="center">
<label for="Institution"><FONT color=white>Institution</label>
<br/>
<input type="text" id="Institution" name="Institution"required/>
</p>
<p align="center">
<label for="Run number "><FONT color=white>Run number </label>
<br/>
<input type="int" id="Run number" name="Run number"required/>
</p>
<p align="center">
<label for="Obtained reads"><FONT color=white>Obtained reads</label>
<br/>
<input type="int" id="Obtained reads" name="Obtained reads"required/>
</p>
<p align="center">
<label for="Re run Info"><FONT color=white>Re run Info</label>
<br/>
<input type="text" id="Re run Info" name="Re run Info"required/>
</p>
<p align="center">
<label for="Total reads"><FONT color=white>Total reads</label>
<br/>
<input type="int" id="Total reads" name="Total reads"required/>
</p>
<p align="center">
<label for="Run date"><FONT color=white>Run date</label>
<br/>
<input type="date" id="Run date" name="Run date"required/>
</p>
<p align="center">
<label for="Raw data location"><FONT color=white>Raw data location</label>
<br/>
<input type="varchar" id="Raw data location" name="Raw data location"required/>
</p>
<p align="center">
<label for="Analyst"><FONT color=white>Analyst</label>
<br/>
<input type="varchar" id="Analyst" name="Analyst"required/>
</p>
<p align="center">
<label for="Mentor"><FONT color=white>Mentor</label>
<br/>
<input type="text" id="Mentor" name="Mentor"required/>
</p>
<p align="center">
<label for="Analysis start date"><FONT color=white>Analysis start date</label>
<br/>
<input type="date" id="Analysis start date" name="Analysis start date"required/>
</p>
<p align="center">
<label for="Analysis end date"><FONT color=white>Analysis end date</label>
<br/>
<input type="date" id="Analysis end date" name="Analysis end date"required/>
</p>
<p align="center">
<label for="Report location"><FONT color=white>Report location</label>
<br/>
<input type="varchar" id="Report location" name="Report location"required/>
</p>
</fieldset>
<div style="text-align:center">
<button action= "process.php" method="post" >
<img alt="ok" src=
"http://www.blueprintcss.org/blueprint/plugins/buttons/icons/tick.png" />
UPDATE
</button>
</form>
the above script is saved in "process.html"
now below PHP script.
<?php
define('DB_NAME','ProcessTrackingSystem');
define('DB_USER','root');
define('DB_PASSWORD','');
define('DB_HOST','localhost');
$link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$link){
die('couldnot connect:'.mysql_error());
}
$db_selected=mysql_select_db(DB_NAME,$link);
if(!$db_selected){
die('cannot use'.DB_NAME.':'.mysql_error());
}
$value1 =$_POST['SO_ID'];
$value2 =$_POST['No.of samples'];
$value3 =$_POST['Sample name'];
$value4 =$_POST['Client name'];
$value5 =$_POST['Institution'];
$value6 =$_POST['Run number '];
$value7 =$_POST['Obtained reads'];
$value8 =$_POST['Re run Info'];
$value9 =$_POST['Total reads'];
$value10 =$_POST['Run date'];
$value11 =$_POST['Raw data location'];
$value12 =$_POST['Analyst'];
$value13 =$_POST['Mentor'];
$value14 =$_POST['Analysis start date'];
$value15 =$_POST['Analysis end date'];
$value16 =$_POST['Report location'];
$sql="INSERT INTO ProcessDetails (SO_ID, No.of_samples, Sample_name, Client_name, Institution, Run_number, Obtained_reads, Re_run_Info, Total_reads, Run_date, Raw_data_location, Analyst, Mentor, Analysis_start_date, Analysis_end_date, Report_location) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5','$value6', '$value7', '$value8', '$value9', '$value10','$value11', '$value12', '$value13', '$value14', '$value15','$value16')";
if(!mysql_query($sql)){
die('error:'.mysql_error());
}
header('Location:process.html');
mysql_close();
?>
now if i enter the data into html form, its showing error that "error:Unknown column 'No.of_samples' in 'field list'".
anyone help me out to fix this error and get desired output.
Thanks in advance....
Assuming that a No.of_samples column exists in your table, quote the name with backticks (`) in your query:
$sql="INSERT INTO ProcessDetails (SO_ID, `No.of_samples`, Sample_name, Client_name, Institution, Run_number, Obtained_reads, Re_run_Info, Total_reads, Run_date, Raw_data_location, Analyst, Mentor, Analysis_start_date, Analysis_end_date, Report_location) VALUES ('$value1', '$value2', '$value3', '$value4', '$value5','$value6', '$value7', '$value8', '$value9', '$value10','$value11', '$value12', '$value13', '$value14', '$value15','$value16')";
Also, you might want to look into SQL injection security risks, and into using the non-deprecated mysqli_* functions instead of the deprecated mysql_* ones.
You are inserting to column No.of_samples which does not exist!
This is the code for the form:
<div id="regform">
<div id="regform-top">
<h2>User Registration</h2>
<p>Please complete this form</p>
</div>
<form id="register-form" name="register-form" action="submit.php" method="post"
class="validation">
<fieldset>
<table>
<tr>
<td>
<div class="fieldgroup">
<label for="user-name">User name*: </label>
<input type="text" id="name" name="name" value="" size="12" class="inpt" /><br
class="clear" />
</div>
<div class="fieldgroup">
<label for="password">Password*: </label>
<input type="password" id="password" name="password" value="" size="12" class="inpt"
/><br class="clear" />
</div>
</td>
<td id="form-note">
<br />
<p><strong>Form Instructions</strong></p>
<p>*Required Field</p>
</td>
</tr>
</table>
<table id="bottom-reg">
<tr>
<td><br />
<div class="fieldgroup">
<label for="firstname">First name*</label>
<input type="text" id="firstname" name="firstname" value="" size="12" class="inpt" />
<br class="clear" />
</div>
<div class="fieldgroup">
<label for="email">Email Address* </label>
<input type="text" id="email" name="email" value="" size="12" class="inpt" /><br
class="clear" />
</div>
<div class="fieldgroup">
<label for="address1">Address 1* </label>
<input type="text" id="address1" name="address1" value="" size="12" class="inpt" />
<br class="clear" />
</div>
<label for="address2">Address 2</label>
<input type="text" id="address2" name="address2" value="" size="12" class="inpt" />
<br class="clear" />
<label for="address2">Address 3</label>
<input type="text" id="address3" name="address3" value="" size="12" class="inpt" />
<br class="clear" />
<div class="fieldgroup">
<label for="country">Country*</label>
<input type="text" id="country" name="country" value="" size="12" class="inpt" /><br
class="clear" />
</div>
</td>
<td><br />
<div class="fieldgroup">
<label for="lastname">Last name*</label>
<input type="text" id="lastname" name="lastname" value="" size="12" class="inpt" />
<br class="clear" />
</div>
<div class="fieldgroup">
<label for="group">Group* </label>
<input type="text" id="name" name="group" value="" size="12" class="inpt" />
<br class="clear" />
</div>
<div class="fieldgroup">
<label for="city">City* </label>
<input type="text" id="city" name="city" value="" size="12" class="inpt" /><br
class="clear" />
</div>
<div class="fieldgroup">
<label for="city">State* </label>
<input type="text" id="state" name="state" value="" size="12" class="inpt" /><br
class="clear" />
</div>
<div class="fieldgroup">
<label for="zip">Zip*</label>
<input type="text" id="zip" name="zip" value="" size="12" class="inpt" /><br
class="clear" />
</div>
</td>
</tr>
</table>
<input type="submit" value="Register" class="submit-btn" />
</fieldset>
</form>
This is the code for submit.php:
<?php
$con = mysql_connect("localhost","viatechp_invacar","storefront72");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("viatechp_invacare", $con);
$sql="INSERT INTO registration(username,password,fname,lname,group,
address1,address2,address3, email,city,state,zip,country )
VALUES
('$_POST[name]','$_POST[password]', '$_POST[firstname]','$_POST[lastname]','
$_POST[group]','$_POST[address1]','$_POST[address2]','$_POST[address3]',
'$_POST[email]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[country]'
)" ;
$query = mysql_query($sql) or die(mysql_error());
$results = mysql_fetch_assoc($query);
if ($results) {
echo 'The query returned ' . $results[ 'registration' ];
} else {
echo 'The query did not return any results';
} ?>
echo $sql;
?>
It is showing an error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group,address1,address2,address3,email,city,state,zip,country ) VALUES ( 'sdfdsf' at line 1
group is an SQL keyword. If this is the name of one of your fields you must enclose it with ` like so:
`group`,`address1`,...
This tells mySQL that it is a field name and not the keyword. It would be good practice to enclose all your fields within ` to prevent any errors like this you may not have noticed.
Spot on by pburgess. GROUP, ORDER are some common field names that we use while programming. Make sure to enclose these using backticks group, always a good practice.
$sql="INSERT INTO registration(username,password,fname,lname,`group`,
address1,address2,address3, email,city,state,zip,country )
VALUES
('$_POST[name]','$_POST[password]', '$_POST[firstname]','$_POST[lastname]','
$_POST[group]','$_POST[address1]','$_POST[address2]','$_POST[address3]',
'$_POST[email]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[country]'
)" ;
Try this
$sql="INSERT INTO registration(`username`,`password`,`fname`,`lname`,`group`,
`address1`,`address2`,`address3`, `email`,`city`,`state`,`zip`,`country` )
VALUES
('$_POST[name]','$_POST[password]', '$_POST[firstname]','$_POST[lastname]',
'$_POST[group]','$_POST[address1]','$_POST[address2]','$_POST[address3]',
'$_POST[email]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[country]')" ;
Because you got some field names which is reserved keywords like for example you have group
Your $_POST values is missing quotes, Try updating them
$sql="INSERT INTO registration
(`username`,`password`,`fname`,`lname`,`group`,`address1`,`address2`,`address3`, `email`,`city`,`state`,`zip`,`country`)
VALUES
('$_POST[\"name\"]','$_POST[\"password\"]',$_POST[\"firstname\"]','$_POST[\"lastname\"]','
$_POST[\"group\"]','$_POST[\"address1\"]','$_POST[\"address2\"]','$_POST[\"address3\"]',
'$_POST[\"email\"]','$_POST[\"city\"]','$_POST[\"state\"]','$_POST[\"zip\"]','$_POST[\"country\"]'
)" ;
Well it is too late but this might help someone. Whenever you want to check why your query doesnt' work.. Always try to echo your query and paste it to the phpmyadmin and it will throw the mySQL error which are more easy to understand that what's the issue in query
Hi there. Can anyone please tell me how to arrange the list of checkboxes of cuisines label which is retrieved from the data base and when it is displaying it is not in the order coming side by side all together I want it to be displayed in a 3 by 3 format. Here is the code for that:
<div id="frmform">
<form name="frmrestaurant" id="frmrestaurant" method="post" onsubmit="" enctype="multipart/form-data">
<p class="msgsignup">Add Restaurant</p>
<div id="iderror"></div>
<div class="topinputs">
<div> <label for="restaurant_name" class="name">Restaurant Name :</label><input type="text" name="restaurant_name" size="32" id="restaurant_name" value="<?php echo $row->restaurant_name; ?>" class="validate[required,custom[onlyLetter],length[0,100]] text-input" /> </div>
</div>
<div> <label for="website" class="name">Website :</label><input size="32" type="text" name="website" id="website" value="<?php echo $row->website; ?>" class="validate[required,length[0,100]] text-input" /> </div>
<div> <label for="budget" class="name">Budget :</label>
<?php echo $this->lists['budget'];?>
</div>
<div> <label for="idcuisine" class="cuisine" >Cuisine:</label>
<?php echo $this->lists['cuisine'] ;?>
<div> <label for="idcategory" class="category">Category:</label>
<?php echo $this->lists['category'];?>
</div>
The lists of cuisine and category is not displaying properly.
Thanks.
It could be done with php right logic
<tr>
<?php
while($ofetch=$db->fetchNextObject($query))
{
$j++;
?>
<td width="33%">
<input type="checkbox" name="service[]" id="service" value="<?php echo $ofetch->service_id?>" /> some text
</td>
<?php if($j%3==0) { echo "</tr><tr>";}
}
?>
</tr>