Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

cant find what's wrng/cannot insert

Codes here !

Moderators: macek, egami, gesf

cant find what's wrng/cannot insert

Postby roipatrick » Mon Feb 24, 2014 10:23 am

I need help in checking my code here. Im new to php and cannot insert into mysql using the data found inside text boxes.
HTML
<form class="form-input myprofile-form" action ="application.php" method="post" >
<div class="grid_9">
<div class="group-content form-accordion">
<!--tab 1 start-->
<div class="tab" id="tab1" style="height:400px; width:465px;">
<div class="form-fieldset">
<div class="fieldset-title">Main Information</div>
<div class="fieldset">
<div class="field">
<label>Start Date:</label>
<input type="date" id="datepicker" name='sdate' size='9' value="" />
</div>
<div class="field">
<label>End Date:</label>
<input type="date" id="datepicker" name='edate' size='9' value="" />
</div>
<div class="field">
<label>Remaining:</label>
<input type="text" size='9' name="remaining"/>
</div>
<div class="field">
<label>Leave Type</label>
<select class="custom-select" name="typeofleave">
<option>--Please Select Type--</option>
<option>Sick Leave</option>
<option>Emergency Leave</option>
<option>Paid Leave</option>
<option>UnPaid Leave</option>
</select>
</div>
<div class="field">
<label>Reason</label>
<input type="text" size='9' name="reason"/>
</div>
<div style="text-align:right;">
<input type="submit" />
</div>
</div>


<div class="clear"></div>
</div>
<!--tab 1 end-->


</div>
</div>
</div>
</form>


and here's my php code

<?php
if (isset($_POST["sdate"]) && isset($_POST["edate"]) && isset($_POST["remaining"]) && isset($_POST["reason"]))
{
$stratdate = $_POST["sdate"];
$endaten = $_POST["edate"];
$rem = $_POST["remaining"];
$res = $_POST["reason"];
$con=mysql_connect("127.0.0.1","root","");
// Check connection
if(! $con)
{
die('Connection Failed'.mysql_error());
}
mysql_select_db("leavemanagement",$con);
$sql="INSERT INTO leaveinformation (sdate, edate, remaining, reason)
VALUES
('$stratdate','$endaten','$rem','$res')";
if (!mysql_query($sql,$con))
{
die('salhdasjkhdjahskdhasjdhasdhjkd');
}
echo "Customer Details added Successfully!";
mysql_close($con);
}
?>

now if you will check, eveyrytime i submit the form (textboxes populated), i usually get the "salhdasjkhdjahskdhasjdhasdhjkd" after the die. It does not submit and i dont know why.

Please i need help asap. :help: :help: :help:
roipatrick
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Feb 24, 2014 10:19 am

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.