We help IT Professionals succeed at work.
Get Started

How do I create a sample posting URL string to pass form data?

Last Modified: 2013-12-13
I have created a form that posts data collected from a form into a MySQL database. It works fine, but the client said they need a sample posting url string, so they can use that to pass the form data directly. Can someone please help me.

Here is what I have so far below:
$con = mysql_connect("myserver.com","user","pass"); //Replace with your actual MySQL DB Username and Password
if (!$con) 
die('Could not connect: ' . mysql_error()); 
mysql_select_db("eletha", $con); //Replace with your MySQL DB Name
$firstname=mysql_real_escape_string($_POST['firstname']); //This value has to be the same as in the HTML form file
$lastname=mysql_real_escape_string($_POST['lastname']); //This value has to be the same as in the HTML form file
$address=mysql_real_escape_string($_POST['address']); //This value has to be the same as in the HTML form file
$city=mysql_real_escape_string($_POST['city']); //This value has to be the same as in the HTML form file
$state=mysql_real_escape_string($_POST['state']); //This value has to be the same as in the HTML form file
$email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
$phone=mysql_real_escape_string($_POST['phone']); //This value has to be the same as in the HTML form file
$phone2=mysql_real_escape_string($_POST['phone2']); //This value has to be the same as in the HTML form file
$contactime=mysql_real_escape_string($_POST['contactime']); //This value has to be the same as in the HTML form file
$mortgage_amount=mysql_real_escape_string($_POST['mortgage_amount']); //This value has to be the same as in the HTML form file
$months_behind=mysql_real_escape_string($_POST['months_behind']); //This value has to be the same as in the HTML form file
$zip=mysql_real_escape_string($_POST['zip']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO LEADS (firstname,lastname,address,city,state,email,phone,phone2,contactime,mortgage_amount,months_behind,zip) VALUES ('$firstname','$lastname','$address','$city','$state','$email','$phone','$phone2','$contactime','$mortgage_amount','$months_behind','$zip')"; /*form_data is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
 die('Error: ' . mysql_error()); 
echo "The form data was successfully added to your database.";
echo "<br />";
echo "<br />";
echo "firstname=";
echo $_POST['firstname'];
echo "<br />";
echo "lastname=";
echo $_POST['lastname'];
echo "<br />";
echo "address=";
echo $_POST['address'];
echo "<br />";
echo "city=";
echo $_POST['city'];
echo "<br />";
echo "state=";
echo $_POST['state'];
echo "<br />";
echo "zip=";
echo $_POST['zip'];
echo "<br />";
echo "email=";
echo $_POST['email'];
echo "<br />";
echo "phone=";
echo $_POST['phone'];
echo "<br />";
echo "phone2=";
echo $_POST['phone2'];
echo "<br />";
echo "contact time=";
echo $_POST['contactime'];
echo "<br />";
echo "mortgage amount=";
echo $_POST['mortgage_amount'];
echo "<br />";
echo "months behind=";
echo $_POST['months_behind'];
echo "<br />";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lead Form</title>
<link rel="stylesheet" href="main.css" type="text/css">
<style type="text/css">
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {font-size: 12px}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000066; }
.style5 {color: #000066}
.style6 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000066; font-weight: bold; }
<table width="500" border="0" cellspacing="0" cellpadding="0">
    <td><FORM name='myform' action="leadForm.php" method="POST">
                    <table width="418" height="100%" border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000" class="style8">
                          <td colspan="2"><div align="left" class="style6">LEAD FORM</div></td>
                          <td colspan="2"><div align="left" class="style4">* indicates required field</div></td>
                          <td width="157" valign="middle"><span class="style4">First Name:*</span></td>
                          <td width="247" class="question"><input maxlength=30 size=30 name="firstname" value="" id="firstname" /></td>
                          <td valign="middle"><span class="style4">Last Name:*</span> </td>
                          <td class="question"><input maxlength=30 size=30 name="lastname" id="lastname" /></td>
                          <td valign="middle"><span class="style4">Street Address*</span></td>
                          <td class="question"><input maxlength="30" size="30" name="address" id="address" /></td>
                          <td valign="middle"><span class="style4">City:*</span></td>
                          <td class="question"><input name="city" id="city" size="20" maxlength=20 /></td>
                          <td valign="middle"><span class="style4">State:*</span></td>
                          <td class="question"><select name="state" id="state">
                            <option selected>-- select -- </option>
                            <option value="AL" > Alabama </option>
                            <option value="AK" > Alaska </option>
                            <option value="AZ" > Arizona </option>
                            <option value="AR" > Arkansas </option>
                            <option value="CA" > California </option>
                            <option value="CO" > Colorado </option>
                            <option value="CT" > Connecticut </option>
                            <option value="DE" > Delaware </option>
                            <option value="DC" > District of Columbia </option>
                            <option value="FL" > Florida </option>
                            <option value="GA" > Georgia </option>
                            <option value="HI" > Hawaii </option>
                            <option value="ID" > Idaho </option>
                            <option value="IL" > Illinois </option>
                            <option value="IN" > Indiana </option>
                            <option value="IA" > Iowa </option>
                            <option value="KS" > Kansas </option>
                            <option value="KY" > Kentucky </option>
                            <option value="LA" > Louisiana </option>
                            <option value="ME" > Maine </option>
                            <option value="MD" > Maryland </option>
                            <option value="MA" > Massachusetts </option>
                            <option value="MI" > Michigan </option>
                            <option value="MN" > Minnesota </option>
                            <option value="MS" > Mississippi </option>
                            <option value="MO" > Missouri </option>
                            <option value="MT" > Montana </option>
                            <option value="NE" > Nebraska </option>
                            <option value="NV" > Nevada </option>
                            <option value="NH" > New Hampshire </option>
                            <option value="NJ" > New Jersey </option>
                            <option value="NM" > New Mexico </option>
                            <option value="NY" > New York </option>
                            <option value="NC" > North Carolina </option>
                            <option value="ND" > North Dakota </option>
                            <option value="OH" > Ohio </option>
                            <option value="OK" > Oklahoma </option>
                            <option value="OR" > Oregon </option>
                            <option value="PA" > Pennsylvania </option>
                            <option value="RI" > Rhode Island </option>
                            <option value="SC" > South Carolina </option>
                            <option value="SD" > South Dakota </option>
                            <option value="TN" > Tennessee </option>
                            <option value="TX" > Texas </option>
                            <option value="UT" > Utah </option>
                            <option value="VT" > Vermont </option>
                            <option value="VA" > Virginia </option>
                            <option value="WA" > Washington </option>
                            <option value="WV" > West Virginia </option>
                            <option value="WI" > Wisconsin </option>
                            <option value="WY" > Wyoming </option>
                          <td valign="middle"><span class="style4">Zip:*</span></td>
                          <td class="question"><input maxlength=8 size=8 name="zip" id="zip" /></td>
                          <td valign="middle"><span class="style4">E-mail:*</span></td>
                          <td class="question"><input maxlength="30" size=30 name="email" id="email" /></td>
                          <td valign="middle"><span class="style4">Best Contact #:*</span></td>
                          <td class="question"><input type="text" name="phone" size="15" maxlength="10" id="phone" /></td>
                          <td height="27" valign="middle"><span class="style4">Second Contact #:</span></td>
                          <td class="question"><input type="text" name="phone2" size="15" maxlength="10" id="phone2" /></td>
                          <td valign="middle"><span class="style4">Best Time to Contact?*</span></td>
                          <td class="question"><select name="contactime" id="contactime">
                            <option value="morning" selected="selected">Morning</option>
                            <option value="afternoon">Afternoon</option>
                            <option value="evening">Evening</option>
                          </select>                          </td>
                          <td valign="middle"><span class="style4">Mortgage Amount:*</span></td>
                          <td class="question"><select name="mortgage_amount" id="mortgage_amount">
                            <option value="" selected>Select Range</option>
									<option value="100000">100,001 - 105,000</option>
									<option value="107500">105,001 - 110,000</option>
									<option value="112500">110,001 - 115,000</option>
									<option value="117500">115,001 - 120,000</option>
									<option value="122500">120,001 - 125,000</option>
									<option value="127500">125,001 - 130,000</option>
									<option value="132500">130,001 - 135,000</option>
									<option value="137500">135,001 - 140,000</option>
									<option value="142500">140,001 - 145,000</option>
									<option value="147500">145,001 - 150,000</option>
									<option value="152500">150,001 - 155,000</option>
									<option value="157500">155,001 - 160,000</option>
									<option value="162500">160,001 - 165,000</option>
									<option value="167500">165,001 - 170,000</option>
									<option value="172500">170,001 - 175,000</option>
									<option value="177500">175,001 - 180,000</option>
									<option value="182500">180,001 - 185,000</option>
									<option value="187500">185,001 - 190,000</option>
									<option value="192500">190,001 - 195,000</option>
									<option value="197500">195,001 - 200,000</option>
									<option value="205000">200,001 - 210,000</option>
									<option value="215000">210,001 - 220,000</option>
									<option value="225000">220,001 - 230,000</option>
									<option value="235000">230,001 - 240,000</option>
									<option value="245000">240,001 - 250,000</option>
									<option value="255000">250,001 - 260,000</option>
									<option value="265000">260,001 - 270,000</option>
									<option value="275000">270,001 - 280,000</option>
									<option value="285000">280,001 - 290,000</option>
									<option value="295000">290,001 - 300,000</option>
									<option value="305000">300,001 - 310,000</option>
									<option value="315000">310,001 - 320,000</option>
									<option value="325000">320,001 - 330,000</option>
									<option value="335000">330,001 - 340,000</option>
									<option value="345000">340,001 - 350,000</option>
									<option value="355000">350,001 - 360,000</option>
									<option value="365000">360,001 - 370,000</option>
									<option value="375000">370,001 - 380,000</option>
									<option value="385000">380,001 - 390,000</option>
									<option value="395000">390,001 - 400,000</option>
									<option value="410000">400,001 - 420,000</option>
									<option value="430000">420,001 - 440,000</option>
									<option value="450000">440,001 - 460,000</option>
									<option value="470000">460,001 - 480,000</option>
									<option value="490000">480,001 - 500,000</option>
									<option value="510000">500,001 - 520,000</option>
									<option value="530000">520,001 - 540,000</option>
									<option value="550000">540,001 - 560,000</option>
									<option value="570000">560,001 - 580,000</option>
									<option value="590000">580,001 - 600,000</option>
									<option value="610000">600,001 - 620,000</option>
									<option value="630000">620,001 - 640,000</option>
									<option value="650000">640,001 - 660,000</option>
									<option value="670000">660,001 - 680,000</option>
									<option value="690000">680,001 - 700,000</option>
									<option value="710000">700,001 - 720,000</option>
									<option value="730000">720,001 - 740,000</option>
									<option value="750000">740,001 - 760,000</option>
									<option value="770000">760,001 - 780,000</option>
									<option value="790000">780,001 - 800,000</option>
									<option value="810000">800,001 - 820,000</option>
									<option value="830000">820,001 - 840,000</option>
									<option value="850000">840,001 - 860,000</option>
									<option value="870000">860,001 - 880,000</option>
									<option value="890000">880,001 - 900,000</option>
									<option value="910000">900,001 - 920,000</option>
									<option value="930000">920,001 - 940,000</option>
									<option value="950000">940,001 - 960,000</option>
									<option value="970000">960,001 - 980,000</option>
									<option value="990000">980,001 - 1,000,000</option>
									<option value="1250000">1,000,001 - 1,500,000</option>
									<option value="1750000">1,500,001 - 2,000,000</option>
									<option value="2250000">2,000,001 - 2,500,000</option>
									<option value="2750000">2,500,001 - 3,000,000</option>
									<option value="3250000">3,000,001 - 3,500,000</option>
									<option value="3750000">3,500,001 - 4,000,000</option>
									<option value="4250000">4,000,001 - 4,500,000</option>
									<option value="4750000">4,500,001 - 5,000,000</option>
									<option value="5250000">5,000,001 - 5,500,000</option>
									<option value="5750000">5,500,001 - 6,000,000</option>
									<option value="6250000">6,000,001 - 6,500,000</option>
									<option value="6750000">6,500,001 - 7,000,000</option>
									<option value="7000001">Over 7,000,001</option>
                          </select>                          </td>
                          <td valign="middle"><span class="style4">Months Behind:*</span></td>
                          <td class="question"><select name="months_behind" id="months_behind">
                            <option value="1" selected="selected">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                          </select>                          </td>
                          <td colspan="2" valign="top">&nbsp;</td>
                        <tr class="question">
                          <td height="44" colspan="2" rowspan="2"><div align="center" class="style19 style1 style3 style5">
                            <input value="submit" type="submit" name="submit" />

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE