Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Add New Record</title>
- </head>
- <body>
- <?php
- if(isset($_POST['add'])) {
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = '';
- $db = 'school';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass, $db);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- if(! get_magic_quotes_gpc() ) {
- $Town = addslashes ($_POST['Town']);
- $Unit = addslashes ($_POST['Unit']);
- $Street = addslashes ($_POST['Street']);
- $Name = addslashes ($_POST['Name']);
- $Surname = addslashes ($_POST['Surname']);
- $Tel = addslashes ($_POST['Tel']);
- $Males = addslashes ($_POST['Males']);
- $Females = addslashes ($_POST['Females']);
- $Children = addslashes ($_POST['Children']);
- }else {
- $Town = $_POST['Town'];
- $Unit = $_POST['Unit'];
- $Street = $_POST['Street'];
- $Name = $_POST['Name'];
- $Surname = $_POST['Surname'];
- $Tel = $_POST['Tel'];
- $Males = $_POST['Males'];
- $Females = $_POST['Females'];
- $Children = $_POST['Children'];
- }
- $sql = "INSERT INTO masjid ". "(id,town,unit,street,name,surname,tel,males,females,children,dtAdd) ". "VALUES('','$Town','$Unit','$Street','$Name','$Surname','$Tel','$Males','$Females','$Children',now())";
- mysql_select_db($db);
- $retval = mysql_query( $sql, $conn );
- if(! $retval ) {
- die('Could not enter data: ' . mysql_error());
- }
- echo "Entered data successfully\n";
- echo $sql;
- mysql_close($conn);
- }else {
- }
- ?>
- <form method = "post" action = "<?php $_PHP_SELF ?>">
- <table width = "400" border = "0" cellspacing = "1"
- cellpadding = "2">
- <tr>
- <td width = "100">Town</td>
- <!--The code for musa -->
- <td>
- <?php
- # I am connecting to the database again because the codes used above they
- # are no more suported by php so this is the best way so far
- # Dont forget to change the dbname school to yourown and root plus blunk password
- $conn = new PDO ('mysql:host=localhost;dbname=school','root','');
- if($conn){
- //echo "connected";
- }
- else{
- // echo "Musa db not connected ";
- }
- # Fechinh data from the table town
- $sqlTown = "SELECT tname FROM town";
- $mytown = $conn->prepare($sqlTown);
- $mytown->execute();
- echo "<select name='tname'>";
- while ($row =$mytown->fetch(PDO::FETCH_ASSOC)){
- echo "<option value='" . $row['tname'] . "'>" . $row['tname'] . "</option>";
- }
- echo "</select>";?>
- </td>
- <!--Codes for musa ends-->
- </tr>
- <tr>
- <td width = "100">Unit</td>
- <td><input name = "Unit" type = "text"
- id = "Unit"></td>
- </tr>
- <tr>
- <td width = "100">Street</td>
- <td><input name = "Street" type = "text"
- id = "Street"></td>
- </tr>
- <tr>
- <td width = "100">Name</td>
- <td><input name = "Name" type = "text"
- id = "Name"></td>
- </tr>
- <tr>
- <td width = "100">Surname</td>
- <td><input name = "Surname" type = "text"
- id = "Surname"></td>
- </tr>
- <tr>
- <td width = "100">Tel</td>
- <td><input name = "Tel" type = "text"
- id = "Tel"></td>
- </tr>
- <tr>
- <td width = "100">Males</td>
- <td><input name = "Males" type = "text"
- id = "Males"></td>
- </tr>
- <tr>
- <td width = "100">Females</td>
- <td><input name = "Females" type = "text"
- id = "Females"></td>
- </tr><tr>
- <td width = "100">Children</td>
- <td><input name = "Chilren" type = "text"
- id = "Children"></td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td> </td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td>
- <input name = "add" type = "submit" id = "add"
- value = "Add">
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement