mohanada Posted July 15, 2017 Share Posted July 15, 2017 ============Database============= <?php $conn = mysqli_connect('localhost', 'root','' , 'test' ); if(!$db){ echo mysqli_error($db); return; } echo 'Connection OK'; ?> =============Table================ `SNo`, `Customer Id`, `Card`, `First Name`, `Last Name`, `Gender`, `DOB`, `Age`, `Mobile`, `Address`, `Email Id`, `C Type`, `RefrenceId`, `Country`, `State`, `City`, `entry_date` ========================== <?php include_once('conn.php'); session_start(); if(isset($_POST['submit'])){ $CustomerID= mysqli_real_escape_string($db ,$_POST['cid']); $Card = mysqli_real_escape_string($db ,$_POST['ccode']); $FirstName= mysqli_real_escape_string($db ,$_POST['fname']); $LastName= mysqli_real_escape_string($db ,$_POST['lname']); $Gender= mysqli_real_escape_string($db ,$_POST['gen']); $DOB= mysqli_real_escape_string($db ,$_POST['dob']); $Age= mysqli_real_escape_string($db ,$_POST['age']); $Mobile= mysqli_real_escape_string($db , $_POST['mob1']); $Address= mysqli_real_escape_string($db ,$_POST['add']); $EmailId= mysqli_real_escape_string($db ,$_POST['emailid']); $Cardtyp= mysqli_real_escape_string($db ,$_POST['ctype']); $RefrenceId= mysqli_real_escape_string($db ,$_POST['refno']); $Country= mysqli_real_escape_string($db ,$_POST['country']); $State= mysqli_real_escape_string($db ,$_POST['state']); $City= mysqli_real_escape_string($db ,$_POST['city']); $sql= "INSERT INTO opd VALUES('','$CustomerID','$Card','$FirstName','$LastName','$Gender','$DOB','$Age','$Mobile','$Address','$EmailId','$Cardtyp','$RefrenceId','$Country','$State','$City','".date("Y-m-d")."')"; $qury = mysqli_query($db ,$sql); if(!$qury) echo mysqli_error(); else echo "<script> alert('Data inserted Successfully'); </script>"; header('location:opd_new.php'); } ?> =============================================== <?php include_once('db.php'); $DB_host = 'localhost'; $DB_user = 'root'; $DB_pass = ''; $DB_name = 'test'; try { $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass); $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { $e->getMessage(); } ?> <form action="new_1.php" method="post" name="a" onsubmit="return validateForm();"><table width="102%" border="0"> <thead> <tr> <td>Customer Id </td> <td><input type="text" name="cid" class="text-input" value="<?php echo $rw; ?>" AUTO_INCREMENT="on" readonly="true" /></td> <td>Card No</td> <td><input type="text" name="ccode" class="text-input" value="<?php echo $number; ?>" readonly="readonly"/></td> <td> </td> </tr> <tr> <td><span class="style5">First Name</span></td> <td><input type="text" name="fname" id="fname" class="text-input" onchange="toTitleCase(this)" /></td> <td><span class="style5">Last Name</span></td> <td><input type="text" name="lname" id="lname" class="text-input" onchange="toTitleCase(this)" /></td> <td> </td> </tr> <tr> <td><span class="style5">Gender </span></td> <td><select name="gen" > <option value="Male">Male</option> <option value="Female">Female</option> </select></td> <td>DOB</td> <td><input type="text" id="dob" name="dob" class="tcal tcalinput" onfocus="test();" onblur="setAge();" onkeyup="this.onblur();" onpaste="this.onblur();" oninput="this.onblur();" value="<?php echo date("Y-m-d"); ?>"/></td> <td> </td> </tr> <tr> <td><span class="style5">Age</span></td> <td><input type="text" id="age" name="age" class="text-input" maxlength="3" /></td> <td><span class="style5">Mobile</span></td> <td><input type="text" name="mob1" class="text-input" maxlength="10" /></td> <td> </td> </tr> <tr> <td><span class="style5">Address</span></td> <td><textarea name="add" style="height:22" ></textarea></td> <td><span class="style5">Email Id </td> <td><input type="text" name="emailid" class="text-input" /></td> <td> </td> </tr> <tr> <td>Profession</td> <td><select id="ctype" name="ctype" style="width:36mm" > <option value="Select">Select</option> <option value="Student">Student</option> <option value="Employee">Employee</option> <option value="Doesn'tMatter">Doesn'tMatter</option> <option value="Accounting,Banking,Finance">Accounting,Banking,Finance</option> </select></td> <td>Reference By </td> <td><input type="text" id="refno" name="refno" class="text-input"/></td> <td> </td> </tr><tr><td>Country</td> <td><span class="desc1"> <select name="country" class="country"> <option selected="selected">--Select Country--</option> <?php $stmt = $DB_con->prepare("SELECT * FROM country"); $stmt->execute(); while($row=$stmt->fetch(PDO::FETCH_ASSOC)) { ?> <option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option> <?php } ?> </select></td> <td>State</td> <td><span class="desc1"> <select name="state" class="state"> <option selected="selected">--Select State--</option> </select></td></tr> <tr> <td>City</td> <td><span class="desc1"> <select name="city" class="city"> <option selected="selected">--Select City--</option> </select> </td> </tr> <tr> <td width="139"> </td> <td width="319"> </td> <td width="214"><input type="submit" id="submit" name="submit" value="Submit"></td> <td width="281"> </td> <td width="55"> </td> </tr> </thead> </table> </form> Link to comment Share on other sites More sharing options...
requinix Posted July 15, 2017 Share Posted July 15, 2017 How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
mohanada Posted July 15, 2017 Author Share Posted July 15, 2017 https://stackoverflow.com/questions/45117954/data-not-entered-in-database-through-php-form-mysql Link to comment Share on other sites More sharing options...
Jacques1 Posted July 15, 2017 Share Posted July 15, 2017 The OP decided to move his thread to Stackoverflow, so this discussion is obsolete. Link to comment Share on other sites More sharing options...
gizmola Posted July 16, 2017 Share Posted July 16, 2017 Clearly it's going well on SO haha. Link to comment Share on other sites More sharing options...
Jacques1 Posted July 16, 2017 Share Posted July 16, 2017 If people spent half as much time on writing a good question as they do on copypasting bad questions into every forum they know, we might actually get somewhere ... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.