这是我知道它很乱的代码,我正在重新学习,我的问题是当我转到页面时,查询立即运行我已经使用了该网站的一些建议,但到目前为止都没有奏效,我只是想获取输入的表单数据以插入到我的数据库表中。
<?php require_once('connection.php')?>
<?php //Post Params
$F_name = $_POST['F_name'];
$L_name = $_POST['L_name'];
$Address1 = $_POST['Address1'];
$Address2 = $_POST['Address2'];
$City = $_POST['City'];
$State = $_POST['State'];
$Zip = $_POST['Zip'];
$Email = $_POST['Email'];
$P_number = $_POST['P_number'];
$Contact_pref = $_POST['Contact_pref'];
?>
<?php
//INSERT
$query = " INSERT INTO Consumer_info ( F_name, L_name, Address1, Address2, City, State, Zip, Email, P_number, Contact_pref ) VALUES ( '$F_name', '$L_name', '$Address1', '$Address2', '$City', '$State', '$Zip', '$Email', '$P_number', '$Contact_pref' ) ";
$result = mysql_query($query);
if( $result )
{
echo 'Success';
}
else
{
echo 'You already have signed up thanks';
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="form_style.css" media="screen" />
<title>Database Test</title>
</head>
<body>
<div id="wrapper">
<h1>Text Information form</h1>
<form id="form1" name="form1" action="index.php" method="post">
<label for="F_name">First Name</label><input type="text" name="F_name" id="F_name" />
<br class="clear" />
<label for="L_name">Last Name</label><input type="text" name="L_name" id="L_name" />
<br class="clear" />
<label for="Address1">Address</label><input type="text" name="Address1" id="Address1" />
<br class="clear" />
<label for="Address2">Unit/Apt/Suite</label><input type="text" name="Address2" id="Address2" />
<br class="clear" />
<label for="City">City</label><input type="text" name="City" id="City" />
<br class="clear" />
<label for="State">State</label><select name="State" id="State">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>
<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>
<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>
<option value="WY">WY</option>
</select>
<br class="clear" />
<label for="Zip">Zip</label><input type="text" name="Zip" id="Zip" />
<br class="clear" />
<label for="Email">Email Address</label><input type="text" name="Email" id="Email" />
<br class="clear" />
<label for="P_number">Phone</label><input type="text" name="P_number" id="P_number" />
<br class="clear" />
<label for="Contact_pref">Contact Preferences</label><select name="Contact_pref" id="Contact_pref">
<option value="Email">Email</option>
<option value="Phone">Phone</option>
<option value="Mail">Mail</option>
<option value="None">None</option>
</select>
<br class="clear" />
<input type="hidden" name="Cust_id" id="Cust_id" />
<br class="clear" />
<input type="submit" name="submit" id="submit" value="Submit" />
<br class="clear" />
</form>
</div> <!-- End #wrapper -->
</body>
</html>