I want to send a conditional option value(from HTML select tag) into the MySQL table. I test every method, but with no success. Normal selected option value insert working properly, but conditional option value not inserted, update blank. Also Auto generate number ($client_id = "ICO01";) working for only 10times after not working, after delete datais working again. Does anybody know a solution? This is my code :
`
//database conection
<?php include 'dashboard/dbcon.php' ?>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$query2 = "SELECT * FROM quote_form order by reg desc limit 1";
$result2 = mysqli_query($conn, $query2);
$row = mysqli_fetch_array($result2);
$last_id = $row['reg'];
if ($last_id == "")
{
$client_id = "ICO01";
}
else
{
$client_id = substr($last_id, 3);
$client_id = intval($client_id);
$client_id = "ICO0" . ($client_id + 1);
}
?>
<div class="about-section">
<!--Quote Form-->
<div class="quote-form">
<h3>Get our free consultancy <span>at Your doorsteps</span></h3>
<form action="" method="POST">
<div class="dnone" style="display: ;"><input type="text" id="reg" name="reg" value="<?php echo $client_id; ?>" readonly ><br></div>
<label for="name">Name</label><br>
<input type="text" id="name" name="name" placeholder="Your Name" required><br>
<label for="phone">Phone No</label><br>
<input type="phone" id="phone" name="phone" placeholder="+91 00000 0000" required><br>
<label for="email">Email</label><br>
<input type="email" id="email" name="email" placeholder="youremail#rmail.com" required><br>
<label for="pan">PAN No.</label><br>
<input type="text" id="pan" name="pan" placeholder="ABCTY1234D" required><br>
<label for="address">Address</label><br>
<input type="text" id="address" name="address" placeholder="Your Address" required><br>
<label for="who">Type of Service</label><br>
<select name="service" id="who">
<option value="" disabled selected value class="custom-select">Select One</option>
<option name="service" value="Registration Related Assistance">Registration Related Assistance</option>
<option name="service" value="Licencing Related Assistance">Licencing Related Assistance</option>
<option name="service" value="Financing Related Assistance">Financing Related Assistance</option>
<option name="service" value="Intellectual Properties Related Assistance">Intellectual Properties Related Assistance</option>
<option name="service" value="Taxation Related Assistance">Taxation Related Assistance</option>
<option name="service" value="Companies Act-2013">Companies Act-2013</option>
<option name="service" value="Valuation">Valuation</option>
<option name="service" value="Finance and Accounts">Finance and Accounts</option>
<option name="service" value="Taxation">Taxation</option>
<option name="service" value="RBI & FEMA">RBI & FEMA</option>
<option name="service" value="MSME">MSME</option>
<option name="service" value="Others">Others</option>
</select>
<br><label>Select Service </label><br>
<select class="select" name="blank" id="blank" onchange="location = this.value;">
<option value="" disabled selected value>Select One </option>
</select>
<select name="tser" id="register">
<option name="tser" value="Company registration">Company registration</option>
<option name="tser" value="Start-up Registration" >Start-up Registration</option>
<option name="tser" value="MSME Registration" >MSME Registration</option>
<option name="tser" value="Society/Trust/NGO registration" >Society/Trust/NGO registration</option>
<option name="tser" value="GST Registration" >GST Registration</option>
<option name="tser" value="NBFC Registration" >NBFC Registration</option>
<option name="tser" value="Shops and Establishments Registrations" >Shops and Establishments Registrations</option>
<option name="tser" value="Others" >Others</option>
</select>
<select name="tservice" id="licencing">
<option value="Trade Licence">Trade Licence</option>
<option name="tser" value="Labour, Factory, FSSI, Environment">Labour, Factory, FSSI, Environment</option>
<option name="tser" value="Drug Licence">Drug Licence</option>
<option name="tser" value="Import Export Code, EOU, etc.">Import Export Code, EOU, etc.</option>
<option name="tser" value="Others">Others</option>
</select>
<select name="tservice" id="financing">
<option name="tser" value="Project Reports">Project Reports</option>
<option name="tser" value="CMA data and Projections">CMA data and Projections</option>
<option name="tser" value="Financial Advisory Services for Loan Proposals">Financial Advisory Services for Loan Proposals</option>
<option name="tser" value="Preparation and submission of Loan Proposals to Banks">Preparation and submission of Loan Proposals to Banks</option>
<option name="tser" value="Project Management Consultancy Services">Project Management Consultancy Services</option>
<option name="tser" value="Obtaining Approval of SIPB/FIPB, etc.">Obtaining Approval of SIPB/FIPB, etc.</option>
</select>
<select name="tservice" id="intellectual">
<option name="tser" value="Trademark Application and further Compliances">Trademark Application and further Compliances</option>
<option name="tser" value="Copyright Applications and further Compliances">Copyright Applications and further Compliances</option>
<option name="tser" value="Patent Registration and Further Compliances">Patent Registration and Further Compliances</option>
</select>
<select name="tservice" id="taxat">
<option name="tser" value="Income Tax and GST advisory">Income Tax and GST advisory </option>
<option name="tser" value="Management of ITR/ GST Returns/TDS returns, etc.">Management of ITR/ GST Returns/TDS returns, etc.</option>
<option name="tser" value="Tax management and tax planning">Tax management and tax planning</option>
<option name="tser" value="Compliances with respect to Income tax and GST">Compliances with respect to Income tax and GST</option>
</select>
<select name="tservice" id="companies">
<option name="tser" value="Issue and Allotment of of equity Shares under:">Issue and Allotment of of equity Shares under:</option>
<option name="tser" value="Right Issue ">Right Issue </option>
<option name="tser" value="Private Placement">Private Placement</option>
<option name="tser" value="ESOP">ESOP</option>
<option name="tser" value="Sweat Equity">Sweat Equity</option>
<option name="tser" value="Issue of Preference shares">Issue of Preference shares</option>
<option name="tser" value="Issue of Bonds & Debentures">Issue of Bonds & Debentures</option>
<option name="tser" value="Dematerilization of Securities of Companies">Dematerilization of Securities of Companies</option>
<option name="tser" value="Charge Registration and Modification/ Charge Management">Charge Registration and Modification/ Charge Management</option>
<option name="tser" value="Drafting of Notice/Agenda and Minutes of Meetings">Drafting of Notice/Agenda and Minutes of Meetings</option>
<option name="tser" value="Maintainance of Statutory Registers">Maintainance of Statutory Registers</option>
<option name="tser" value="AGM, Dividend distribution, etc.">AGM, Dividend distribution, etc.</option>
<option name="tser" value="Merger/Demerger and acquisition">Merger/Demerger and acquisition </option>
<option name="tser" value="Liquidition /Winding up">Liquidition /Winding up</option>
</select>
<select name="tservice" id="valuation">
<option name="tser" value="valuation of Shares">valuation of Shares</option>
<option name="tser" value="Valuation of Debentures/Bonds, etc.">Valuation of Debentures/Bonds, etc.</option>
<option name="tser" value="Valuation of Land and Building">Valuation of Land and Building</option>
<option name="tser" value="Valuation of Plant and Machinary">Valuation of Plant and Machinary</option>
</select>
<select name="tservice" id="accounts">
<option name="tser" value="Statutory Audit of Company/LLP/Partnership/NGO,etc.">Statutory Audit of Company/LLP/Partnership/NGO,etc.</option>
<option name="tser" value="Certification of Annual Returns of Companies/LLP">Certification of Annual Returns of Companies/LLP</option>
<option name="tser" value="Internal Audit">Internal Audit</option>
<option name="tser" value="Search Reports for Banks">Search Reports for Banks</option>
<option name="tser" value="Due Diligence Reports for Banks">Due Diligence Reports for Banks</option>
<option name="tser" value="Concurrent Audit">Concurrent Audit</option>
<option name="tser" value="Turnover Certificate ">Turnover Certificate </option>
<option name="tser" value="Net worth Certificate">Net worth Certificate</option>
<option name="tser" value="Loan Utilization Certificate">Loan Utilization Certificate</option>
<option name="tser" value="Book Debt Certificates">Book Debt Certificates</option>
<option name="tser" value="Share Capital Reconcilation Audit Report (Quarterly )">Share Capital Reconcilation Audit Report (Quarterly )</option>
<option name="tser" value="Deposit Certificates (Annualy)">Deposit Certificates (Annualy)</option>
<option name="tser" value="Cash Flow/ALM, etc certificates">Cash Flow/ALM, etc certificates</option>
<option name="tser" value="Certification of Annual Return (MGT-8)">Certification of Annual Return (MGT-8)</option>
<option name="tser" value="Secreterial Audit Report">Secreterial Audit Report </option>
<option name="tser" value="Others">Others</option>
</select>
<select name="tservice" id="taxation">
<option name="tser" value="Tax Audit Report">Tax Audit Report</option>
<option name="tser" value="Appearance at Income Tax Hearings">Appearance at Income Tax Hearings</option>
<option name="tser" value="Income & Expenditure Certificate">Income & Expenditure Certificate</option>
<option name="tser" value="GST Act Compliances, Hearings and Certifications">GST Act Compliances, Hearings and Certifications</option>
</select>
<select name="tservice" id="rbi_fema">
<option name="tser" value="CS Certificate for FDI">CS Certificate for FDI </option>
<option name="tser" value="Reporting to RBI for Inward Remittence">Reporting to RBI for Inward Remittence</option>
<option name="tser" value="Reporting to RBI for any transfer of securities outside Ind">Reporting to RBI for any transfer of securities outside Ind</option>
<option name="tser" value="Approval form RBI and certification as and when require">Approval form RBI and certification as and when require</option>
</select>
<select name="tservice" id="msme">
<option name="tser" value="Govt subsidy and promotional schemes for industries">Govt subsidy and promotional schemes for industries</option>
</select>
<div class="front-hide">
<label for="name">Date of Registration</label><br>
<input type="date" id="rdate" name="rdate" value="please select date"><br>
<label for="name">Deliver Date</label><br>
<input type="date" id="ddate" name="ddate" value="please select date"><br>
<label for="name">Documents Submitted</label><br>
<input type="text" id="doc" name="doc" value="Type here Document Types" required><br>
<label for="name">Documents Uploaded</label><br>
<input type="file" id="filename" name="filename" accept="image/jpg, image/jpeg"><br>
<label for="name">Mode of Enrollment </label><br>
<input type="text" id="mode" name="mode" value="type here enrolment type"><br>
</div>
<textarea name="tser" name="tser" id="others" rows="3" cols="50" placeholder="Please Input which Type Service are you Looking for.."></textarea>
<br><input type="submit" value="Send Now" class="submit-btn">
</form>
</div>
<!--End Quote Form-->
</div>
<?php
//form data pickup by php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$reg = $_POST['reg'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$pan = $_POST['pan'];
$address = $_POST['address'];
$service = $_POST['service'];
$tservice = $_POST['tser'];
$rdate = $_POST['rdate'];
$ddate = $_POST['ddate'];
$doc = $_POST['doc'];
$filename = $_POST['filename'];
$mode = $_POST['mode'];
//extract($_POST);{
if($name != ""){
//$query = "INSERT INTO contact_form VALUES ( '$name', '$email', '$phone', '$subject', '$discription')";
$query = "INSERT INTO `quote_form` (`id`, `reg`, `name`, `phone`, `email`, `pan`, `address`, `tservice`, `dservice`, `register`, `delivery`, `doc`, `img`, `mode`) VALUES (NULL, '$reg', '$name', '$phone', '$email', '$pan', '$address', '$service', '$tservice', '$rdate', '$ddate', '$doc', '$filename', '$mode')";
$data = mysqli_query ($conn, $query);
if($data){
echo '<script type="text/javascript">';
echo 'alert("Your Request is Succefully Sumitted, Please be Patient, We contact You Soon..")';
echo '</script>';
?>
<meta http-equiv = "refresh" content = "0; url = quote.php" />
<?php
}
else{
echo '<script type="text/javascript">';
echo 'alert("Something Wrong, Please try Again")';
echo '</script>';
}
}
}
?>
`
I will try to find solution or apply many solutions but not working, please help
not need name attribute in <option> tag.
<option value="Trademark Application and further Compliances">Trademark Application and further Compliances</option>
Related
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ShipOnline System</title>
</head>
<body>
<h1>ShipOnline System Request Page</h1>
<form method="post" action="request.php">
<fieldset>
<fieldset>
<legend>Item Information:</legend>
<p><label for="description">Description:</label>
<input type="text" name= "description" id="description" maxlength="100" size="20" required="required"/></p>
<p><label for="weight">Weight (kg):</label>
<select name="weight" id="weight" required="required">
<option value="">Please Select</option>
<option value="weight">0-2</option>
<option value="weight">3</option>
<option value='weight'>4</option>
<option value='weight'>5</option>
<option value='weight'>6</option>
<option value='weight'>7</option>
<option value='weight'>8</option>
<option value='weight'>9</option>
<option value='weight'>10</option>
<option value='weight'>11</option>
<option value='weight'>12</option>
<option value='weight'>13</option>
<option value='weight'>14</option>
<option value='weight'>15</option>
<option value='weight'>16</option>
<option value='weight'>17</option>
<option value='weight'>18</option>
<option value='weight'>19</option>
<option value='weight'>20</option>
</select></p>
</fieldset>
<fieldset>
<legend>Pick-up Information:</legend>
<p><label for="pickupAddress">Street Address:</label>
<input type="text" name= "pickupAddress" id="pickupAddress" maxlength="40" size="30" required="required"/></p>
<p><label for="pickupSuburb">Suburb:</label>
<input type="text" name= "pickupSuburb" id="pickupSuburb" maxlength="40" size="20" required="required"/></p>
<p><label for="date">Preferred date:</label>
<select name="day" id="date" required="required">
<option value="">Day</option>
<option value="day">1</option>
<option value="day">2</option>
<option value="day">3</option>
<option value='day'>4</option>
<option value='day'>5</option>
<option value='day'>6</option>
<option value='day'>7</option>
<option value='day'>8</option>
<option value='day'>9</option>
<option value='day'>10</option>
<option value='day'>11</option>
<option value='day'>12</option>
<option value='day'>13</option>
<option value='day'>14</option>
<option value='day'>15</option>
<option value='day'>16</option>
<option value='day'>17</option>
<option value='day'>18</option>
<option value='day'>19</option>
<option value='day'>20</option>
<option value='day'>21</option>
<option value='day'>22</option>
<option value='day'>23</option>
<option value='day'>24</option>
<option value='day'>25</option>
<option value='day'>26</option>
<option value='day'>27</option>
<option value='day'>28</option>
<option value='day'>29</option>
<option value='day'>30</option>
<option value='day'>31</option>
</select>
<select name="month" id="date" required="required">
<option value="">Month</option>
<option value='month'>1</option>
<option value='month'>2</option>
<option value='month'>3</option>
<option value='month'>4</option>
<option value='month'>5</option>
<option value='month'>6</option>
<option value='month'>7</option>
<option value='month'>8</option>
<option value='month'>9</option>
<option value='month'>10</option>
<option value='month'>11</option>
<option value='month'>12</option>
</select>
<select name="year" id="date" required="required">
<option value="">Year</option>
<option value='year'>2018</option>
<option value='year'>2019</option>
<option value='year'>2020</option>
<option value='year'>2021</option>
</select></p>
<p><label for="time">Prefered time:</label>
<select name="time" id="time" required="required">
<option value="">Please Select</option>
<option value="time">7:30-8:30</option>
<option value="time">8:30-9:30</option>
<option value="time">9:30-10:30</option>
<option value="time">10:30-11:30</option>
<option value="time">11:30-12:30</option>
<option value="time">12:30-13:30</option>
<option value="time">13:30-14:30</option>
<option value="time">14:30-15:30</option>
<option value="time">15:30-16:30</option>
<option value="time">16:30-17:30</option>
<option value="time">17:30-18:30</option>
<option value="time">18:30-19:30</option>
<option value="time">19:30-20:30</option>
</select></p>
</fieldset>
<fieldset>
<legend>Delivery Information:</legend>
<p><label for="receiver">Receiver Name:</label>
<input type="text" name= "receiver" id="receiver" maxlength="40" size="20" pattern="^[a-zA-Z ]+$" required="required"/></p>
<p><label for="deliveryAddress">Street Address:</label>
<input type="text" name= "deliveryAddress" id="deliveryAddress" maxlength="40" size="30" required="required"/></p>
<p><label for="deliverySuburb">Suburb:</label>
<input type="text" name= "deliverySuburb" id="deliverySuburb" maxlength="40" size="20" required="required"/></p>
<p><label for="state">State:</label>
<select name="state" id="state" required="required">
<option value="">Please Select</option>
<option value="state">VIC</option>
<option value="state">NSW</option>
<option value="state">QLD</option>
<option value="state">NT</option>
<option value="state">WA</option>
<option value="state">SA</option>
<option value="state">TAS</option>
<option value="state">ACT</option>
</select></p>
</fieldset>
<br/>
<input type= "submit" value="Request"/>
</fieldset>
</form>
<p>Home</p>
</body>
</html>
PHP:
<?php
require_once ("settings.php"); //connection info
$conn = #mysqli_connect($host,
$user,
$pwd,
$sql_db
);
$requestID = trim($_POST["requestID"]);
$customerID = trim($_POST["customerID"]);
$requestDate = trim($_POST["requestDate"]);
$description = trim($_POST["description"]);
$weight = trim($_POST["weight"]);
$pickupAddress = trim($_POST["pickupAddress"]);
$pickupSuburb = trim($_POST["pickupSuburb"]);
$date = trim($_POST["date"]);
$time = trim($_POST["time"]);
$receiver = trim($_POST["receiver"]);
$deliveryAddress = trim($_POST["deliveryAddress"]);
$deliverySuburb = trim($_POST["deliverySuburb"]);
$state = trim($_POST["state"]);
$sql_table="Request";
$query = "insert into $sql_table (description, weight, pickupAddress, pickupSuburb, date, time, receiver, deliveryAddress, deliverySuburb, state) values ('$description', '$weight', '$pickupAddress', '$pickupSuburb', '$date', '$time', '$receiver', '$deliveryAddress', '$deliverySuburb', '$state')";
//execute the query -we should really check to see if the batabase exists first.
$result = mysqli_query($conn, $query);
//checks if the exeution was succcessful
if (!$result) {
echo "<p class=\"wrong\">Something is wrong with your request please go back and check your details</p>";
// would not show in a production script
} else {
// display an operation successful message
echo "<p class=\"ok\">Thank you! Your request number is requestID. The cost is <cost>. We will pick-up the item at $time on $date.</p>";
} // if successful query operation
// close the database connection
mysqli_close($conn);
// if successful database connection
?>
I have a similar PHP document to this one which works perfectly. I believe the that I keep getting the message "Something is wrong with your request please go back and check your details" because of the 'date', 'time' or the drop boxes which are 'weight' and 'state' but I tried removing them and nothing changed I kept getting that there was something wrong. I can't seem to figure out what is causing the form to not successfully send. Could someone please try and find the error?
I'm utilizing an html form and php to add data to a MySQL database. I've been able to establish a connection, and have the php script add a new record to the database, however, all fields are always empty. I've looked at solutions here and elsewhere, redone my script a few times, and still come up with the same issue.
Any help would be appreciated, php is new to me.
HTML
<label for="custFirstName">First Name</label>
<input type="text" id="custFirstName" placeholder="John">
<label for="custLastName">Last Name</label>
<input type="text" id="custLastName" placeholder="Doe">
<label for="custStreet">Street Address</label>
<input type="text" id="custStreet" placeholder="1234 Cedar Street">
<label for="custCity">City</label>
<input type="text" id="custCity" placeholder="Beverly Hills">
<label for="custState">State</label>
<select id="custState">
<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="DC">DC</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>
<label for="custZipcode">Zip Code</label>
<input type="text" id="custZipcode" placeholder="90210">
<label for="custTX">Telephone Number</label>
<input type="text" id="custTX" placeholder="555-555-5555">
<label for="custEmail">Email Address</label>
<input type="email" id="custEmail" placeholder="name#example.com">
<button type="submit" name="submit">Submit</button>
</form>
PHP
<?php
$con = mysqli_connect('localhost','root','');
if(!con) {
echo 'Error: Not connected to the server.';
}
if(!mysqli_select_db($con,'dBaseName')) {
echo 'Error: Database is not selected';
}
if(isset($_POST['submit'])) {
$custFirstName = $_POST['custFirstName'];
$custLastName = $_POST['custLastName'];
$custStreet = $_POST['custStreet'];
$custCity = $_POST['custCity'];
$custState = $_POST['custState'];
$custZipcode = $_POST['custZipcode'];
$custTX = $_POST['custTX'];
$custEmail = $_POST['custEmail'];
$sql = "INSERT INTO Customer (custFirstName,custLastName,custStreet,custCity,custState,custZipcode,custTX,custEmail) VALUES ('$custFirstName','$custLastName','$custStreet','$custCity','$custState','$custZipcode','$custTX','$custEmail')";
if(!mysqli_query($con,$sql)) {
echo 'Error: There was a problem adding the record to the database.';
}
else {
echo 'Your information was successfully added to the database.';
}
}
header("refresh:2; url=http://www.success.html");
?>
You are using wrong tags, instead of id you need to use name. For example:
<input type="text" id="custZipcode" name="custZipcode" placeholder="90210">
You need to use "name" attribute in all your input and select tag, e.g:
<input type="text" name="custFirstName" id="custFirstName" placeholder="John">
Thanks
I am currently working on a project where a user can review a product then when they "Submit", the UserID & PreferenceID are picked up from the DB & passed into another table in the DB using php/mysql.
The UserID is displayed when they are logged in.
Here is some of the code:
$user_id = $_GET['CustomerID'];
$DissCustPref_PrefID = $_GET['DissCustPref_PrefID'];
$Cigar_CigarID = $_GET['Cigar_CigarID'];
$SmokingTime = $_GET['SmokingTime'];
$CigarFlavour = $_GET['CigarFlavour'];
$FlavourStrength = $_GET['FlavourStrength'];
$Body = $_GET['Body'];
$AfterTaste = $_GET['AfterTaste'];
$Age = $_GET['Age'];
$ValueForMoney = $_GET['ValueForMoney'];
$OverallRating = $_GET['OverallRating'];
$user_id = $row->CustomerID;
print "<br>User ID: ";
echo($user_id);
$query = "INSERT INTO DissReview values
('null','.$user_id','.$DissCustPref_PrefID','$Cigar_CigarID',
'$SmokingTime','$CigarFlavour','$FlavourStrength','$Body',
'$AfterTaste','$Age','$ValueForMoney','$OverallRating')";
At the moment the URL looks like: http://www.somewebsite/foldername/Login/PreviousReviews.php?CustomerID=%24user_id&CustPref_PrefID=%24PrefID&CigarID=2&SmokingTime=2&CigarFlavour=6&FlavourStrength=5&Body=4&AfterTaste=2&Age=2&ValueForMoney=2&OverallRating=4
as you can see it is not getting the userID or the Preference ID.
It should look like CustomerID=1.... and so on.
I have tried using '".UserID."' but this does not work.
Any suggetions?
EDIT ------ Here is the form used to send the data:
Please add your review of the cigar here!
CIGAR
<textarea style="display:none;"></textarea>
<!--This is the rating for the amount of time it took to smoke.-->
<p> Units below are represented in minutes.</p>
<select name="SmokingTime">
<option value="0"> Please Select an Option</option>
<option value="1">15</option>
<option value="2">30</option>
<option value="3">45</option>
<option value="4">60</option>
<option value="5">61+</option>
</select>
<div id="FChart" class="FChart">
<p> <img src="cigar-flavors-wheel.png" alt="Cigar Flavour Wheel" style="width:500px;height:500px;"></p>
</div>
<!--This is the rating for how the cigar tastes.-->
<p> Please select what the cigar tastes like.</p>
<select name="CigarFlavour">
<option value="0"> Please Select an Option</option>
<option value="1">Flowers</option>
<option value="2">Plants</option>
<option value="3">Herbs and Spices</option>
<option value="4">Earths and Minerals</option>
<option value="5">Fruit</option>
<option value="6">Nuts</option>
<option value="7">Chocolate</option>
<option value="8">Coffee</option>
<option value="9">Cream</option>
<option value="10">Leather</option>
</select>
<!--This is the rating for the strength of the flavour.-->
<p> Please select how strong the taste is.</p>
<select name="FlavourStrength">
<option value="0"> Please Select an Option</option>
<option value="1">Very Weak</option>
<option value="2">Weak</option>
<option value="3">Mild</option>
<option value="4">Strong</option>
<option value="5">Very Strong</option>
</select>
<!--This is the rating for how the cigar is: Medium body for example.-->
<p> Please Select the body of the cigar.</p>
<select name="Body">
<option value="0"> Please Select an Option</option>
<option value="1">Mild</option>
<option value="2">Medium</option>
<option value="3">Medium Full</option>
<option value="4">Full</option>
</select>
<!--This is the rating for the strength of the after taste.-->
<p> Please Describe the Strength of the After taste.</p>
<select name="AfterTaste">
<option value="0"> Please Select an Option</option>
<option value="1">Very Weak</option>
<option value="2">Weak</option>
<option value="3">Mild</option>
<option value="4">Strong</option>
<option value="5">Very Strong</option>
</select>
<!--This is the rating for the age of the cigar.-->
<p> Please select a rough age of the cigar.</p>
<select name="Age">
<option value="0"> Please Select an Option</option>
<option value="1">6 Months</option>
<option value="2">1 Year</option>
<option value="3">2 Years</option>
<option value="4">3 Years</option>
<option value="5">4 years</option>
<option value="6">4+ years</option>
</select>
<!--This is the rating for the value for money.-->
<p> Please Describe the value for money aspect.</p>
<select name="ValueForMoney">
<option value="0"> Please Select an Option</option>
<option value="1">Very Poor</option>
<option value="2">Poor</option>
<option value="3">Reasonable</option>
<option value="4">Good</option>
<option value="5">Very Good</option>
</select>
<!--This is the overall rating of the cigar.-->
<p> Please select an overall rating of the cigar.</p>
<select name="OverallRating">
<option value="0"> Please Select an Option</option>
<option value="1">Very Poor</option>
<option value="2">Poor</option>
<option value="3">Reasonable</option>
<option value="4">Good</option>
<option value="5">Very Good</option>
</select>
">
I am echoing the $UserID as debugging to see if it is picking it up.
It just show the $user_id
because you have this code :
echo($user_id);
And you should have some controls on user inputs ! hackers can easily do some Sql injections.
for example use :
mysqli_real_escape_string($input);
Could anyone help please?
trying to create a page for calendar entries for a band that they can update themselves on their own site.
html entry page:
<form action="addgigtimes.php" method="POST">
<fieldset class='multi'>
<legend><h5>Gig 1</h5></legend>
<label for='weekday' class='accessAid'></label>
<select id='weekday' name='weekday'>
<option value='' selected>Day of week</option>
<option value='Monday'>Monday</option>
<option value='Tuesday'>Tuesday</option>
<option value='Wednesday'>Wednesday</option>
<option value='Thursday'>Thursday</option>
<option value='Friday'>Friday</option>
<option value='Saturday'>Saturday</option>
<option value='Sunday'>Sunday</option></select>
<label for='day' class='accessAid'></label>
<select id='day' name='day'><option value='' selected>--Day--</option>
<option value='01'>01</option>
<option value='02'>02</option>
<option value='03'>03</option>
<option value='04'>04</option>
<option value='05'>05</option>
<option value='06'>06</option>
<option value='07'>07</option>
<option value='08'>08</option>
<option value='09'>09</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option></select>
<label for='month' class='accessAid'></label>
<select id='month' name='month'><option value='' selected>--Month--</option>
<option value='01'>01 (Jan)</option>
<option value='02'>02 (Feb)</option>
<option value='03'>03 (Mar)</option>
<option value='04'>04 (Apr)</option>
<option value='05'>05 (May)</option>
<option value='06'>06 (Jun)</option>
<option value='07'>07 (Jul)</option>
<option value='08'>08 (Aug)</option>
<option value='09'>09 (Sep)</option>
<option value='10'>10 (Oct)</option>
<option value='11'>11 (Nov)</option>
<option value='12'>12 (Dec)</option></select>
<label for='year' class='accessAid'></label><select id='year' name='year'>
<option value='' selected>--Year--</option>
<option value='2015'>2015</option>
<option value='2016'>2016</option>
</select>
venue
<input type="text" class="input" name="venue" />
location
<input type="text" class="input" name="location" />
time
<input type="text" class="input" name="time" />
</fieldset>
<button type="reset" style="border: 0; background: transparent">
<img src="images/reset.jpg" alt="reset" style="margin-right:19px "/>
</button>
<button type="submit" value="submit" style="border: 0; background:transparent">
<img src="images/submit.jpg" alt="submit" />
</button>
</form>
I will repeat the fieldset code 30 times so the band can enter a max of 30 gigs at once.
here is the php code:
$sql = "DELETE FROM gigtimes";
$weekday = $_POST['weekday'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$venue = $_POST['venue'];
$location = $_POST['location'];
$time = $_POST['time'];
$rt=mysql_query("insert into guestbook(weekday,day,month,year,venue,location,time) VALUES ('$weekday','$day','$month','$year','$venue','$location','$time')");
echo mysql_error();
So basically delete whats already on the database then update.
I'm just not sure how to go about the row ids? Could anyone explain.
Thanks,
Bettsy
I have a band like website in production, so I know your pain. One thing I do is insert the band name as well, so that way if the band wants to delete something, it searches for their name and deletes the field such as:
$sql = "DELETE FROM gigtimes WHERE band_name = '$band_name'";
It's not perfect, because in theory there could be multiple bands with the same name, so to prevent that, make band names unique. This works perfectly for me. Let me know if you need more information.
i have one big form.. there have some so many select option. and its from to mail function. bellow is my code
<label>Type of Event? </label>
<select id="eventtype" title="" name="eventtype" class="required select">
<option value="">Select Your Event Type</option>
<option value="WEDDINGS">WEDDINGS</option>
<option value="CORPORATE">CORPORATE EVENT</option>
<option value="SPECIAL">SPECIAL EVENT</option>
<option value="OTHER">OTHER SINGLE SERVICES</option>
</select>
<div class="cls"></div>
<div class="container">
<div class="WEDDINGS">
<label>Package</label>
<select name="Package" id="Package">
<option value="Day Of Coordination">Day Of Coordination</option>
<option value="Week of Coordination">Week of Coordination</option>
<option value="Month of Coordination">Month of Coordination</option>
</select>
</div>
<div class="CORPORATE">
<label>Package</label>
<select name="Package" id="Package">
<option value="Meetings">Meetings</option>
<option value="Client Appreciation">Client Appreciation</option>
<option value="Conference & Conventions">Conference & Conventions</option>
<option value="Corporate Shows">Corporate Shows</option>
<option value="Employee Appreciation">Employee Appreciation</option>
</select>
</div>
<div class="SPECIAL">
<label>Package</label>
<select name="Package" id="Package">
<option value="Engagements">Engagements</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Quincearas">Quincearas</option>
<option value="Birthdays">Birthdays</option>
<option value="Fashion Shows">Fashion Shows</option>
<option value="Showers">Showers</option>
</select>
</div>
<div class="OTHER">
<label>Package</label>
<select name="Package" id="Package">
<option value="Wedding Consultation and Guidance Only">Wedding Consultation and Guidance Only</option>
<option value="Venue Search Only">Venue Search Only</option>
<option value="Coordination of Engagement Party Only">Coordination of Engagement Party Only</option>
<option value="Providing Qualified and Screened Vendors Only">Providing Qualified and Screened Vendors Only</option>
</select>
js code for realtion with drop down
<script>
$(document).ready(function() {
$('#eventtype').bind('change', function() {
var elements = $('div.container').children().hide();
var value = $(this).val();
if (value.length) {
elements.filter('.' + value).show();
}
}).trigger('change');
});
</script>
my from is like if select WEDDING then show Wedding div so show there another drop down.. and if select CORPORATE EVENT then show CORPORATE EVENT div... but no matter what drop down i select when mail go correct data not pass. its goes always OTHER div 1st select value mean "Wedding Consultation and Guidance Only" ... i have no idea why... may be i mistake something... bellow is part of php mail code
if($violation)
{
$eventtype = $_POST['eventtype'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$datepicker = $_POST['datepicker'];
$datepicker2 = $_POST['datepicker2'];
$time = $_POST['time'];
$EMAIL = $_POST['EMAIL'];
$phone = $_POST['phone'];
$Package = $_POST['Package'];
$otherfound = $_POST['otherfound'];
if (isset($_POST['found_group'])) {
$found = $_POST['found_group'];
for ($i=0; $i<count($found); $i++) {
//echo $found[$i]."<br />";
$found=implode("<br />",$found);
}
}
all i want to correct data will go .. can you tell me where i am mistaking... thanks
you may need to do something like this
<label>Type of Event? </label>
<select id="eventtype" title="" name="eventtype" name="eventtype" class="required select">
<option value="">Select Your Event Type</option>
<option value="WEDDINGS">WEDDINGS</option>
<option value="CORPORATE">CORPORATE EVENT</option>
<option value="SPECIAL">SPECIAL EVENT</option>
<option value="OTHER">OTHER SINGLE SERVICES</option>
</select>
<div class="cls"></div>
<div class="container">
<div class="WEDDINGS">
<label>Package</label>
<select name="WEDDINGSPackage" id="WEDDINGSPackage">
<option value="Day Of Coordination">Day Of Coordination</option>
<option value="Week of Coordination">Week of Coordination</option>
<option value="Month of Coordination">Month of Coordination</option>
</select>
</div>
<div class="CORPORATE">
<label>Package</label>
<select name="CORPORATEPackage" id="CORPORATEPackage">
<option value="Meetings">Meetings</option>
<option value="Client Appreciation">Client Appreciation</option>
<option value="Conference & Conventions">Conference & Conventions</option>
<option value="Corporate Shows">Corporate Shows</option>
<option value="Employee Appreciation">Employee Appreciation</option>
</select>
</div>
.......
and at PHP end you have to do something like this
if (isset($_POST['eventtype'])) {
$subOptSelect = $_POST['eventtype'] . 'Package';
if (isset($_POST[$subOptSelect])){
$sub = $_POST[$subOptSelect];
}
}
I have prefixed the value of the first select to the sub selects and it becomes easier at php end.
Edit: Here is the code you may require.
$package='';
if (!empty($eventtype)) {
if (!empty($_POST[$eventtype.'Package'])){
$package = $_POST[$eventtype.'Package'];
//$package contains the option selected in the sub option.
}else{
//nothing selected in the sub dropdown. you have to add code to handle this
}
}else{
//nothing selected in the first dropdown. you have to add code to handle this
}
And your email can be:
<table width='95%' cellpadding='0' cellspacing='11'>
<tr>
<td width='189'>Event Type :</td>
<td>$eventtype</td>
</tr>
<tr>
<td>Package :</td><td>$package</td>
</tr>
<tr>
<td>First Name :</td><td>$firstname</td>
</tr>
<tr>
You can't reuse the name attribute in html, and you're html form has the same name for each select tag. What is happening is the markup is processed sequentially so it only uses the last declaration of the name="Package" select so the selected value from that will always be passed to the server as the $_POST['package']. Do something like this instead:
<label>Type of Event? </label>
<select id="eventtype" title="" name="eventtype" class="required select">
<option value="">Select Your Event Type</option>
<option value="WEDDINGS">WEDDINGS</option>
<option value="CORPORATE">CORPORATE EVENT</option>
<option value="SPECIAL">SPECIAL EVENT</option>
<option value="OTHER">OTHER SINGLE SERVICES</option>
</select>
<div class="cls"></div>
<div class="container">
<div class="WEDDINGS">
<label>Package</label>
<select name="Weddings-Package" id="Weddings-Package">
<option value="Day Of Coordination">Day Of Coordination</option>
<option value="Week of Coordination">Week of Coordination</option>
<option value="Month of Coordination">Month of Coordination</option>
</select>
</div>
<div class="CORPORATE">
<label>Package</label>
<select name="Corporate-Package" id="Corporate-Package">
<option value="Meetings">Meetings</option>
<option value="Client Appreciation">Client Appreciation</option>
<option value="Conference & Conventions">Conference & Conventions</option>
<option value="Corporate Shows">Corporate Shows</option>
<option value="Employee Appreciation">Employee Appreciation</option>
</select>
</div>
<div class="SPECIAL">
<label>Package</label>
<select name="Special-Package" id="Special-Package">
<option value="Engagements">Engagements</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Quincearas">Quincearas</option>
<option value="Birthdays">Birthdays</option>
<option value="Fashion Shows">Fashion Shows</option>
<option value="Showers">Showers</option>
</select>
</div>
<div class="OTHER">
<label>Package</label>
<select name="Other-Package" id="Other-Package">
<option value="Wedding Consultation and Guidance Only">Wedding Consultation and Guidance Only</option>
<option value="Venue Search Only">Venue Search Only</option>
<option value="Coordination of Engagement Party Only">Coordination of Engagement Party Only</option>
<option value="Providing Qualified and Screened Vendors Only">Providing Qualified and Screened Vendors Only</option>
</select>
when the post data is sent to the server it is sent in the $_POST variable as an associative array with the names as the key, if you make the name of each select unique then you should be able to achieve what you want. You might want to pass the name of which select was used to the server so you know which variable to grab in php. As another note the id value for every tag should be unique, as that is the purpose of an id attribute.