Jump to content

php code to accept and delete incoming data


rukshilag

Recommended Posts

Using following HTML Code please show me how to write PHP code to accept and delete the incoming data entered through the form below. from the following MySQL database and table.

Database = hrms

Table = Student

Fields = StdNo(Number), Name(String), Address(String), Contact No(String)

 

 

      Student No<Input type='text' name='txtStdNo' /> <br>

      Name<Input type='text' name='txtName' /> <br>

      Address<Input type='text' name='txtAdd' /> <br>

      Contact No<Input type='text' name='txtTel' /> <br>

      <input type='submit' name='cmdDelete' value='Delete' />

      <input type='submit' name='cmdRetrieve' value='Retrieve' /

      <input type='submit' name='cmdUpdate' value='Update' />

      <input type='submit' name='cmdClose' value='Close' />

TONNNNS of tutorials out there for this kind of stuff.

 

If you're 100% new to php...start with learning the basics.

 

Then learn

- How to connect to a database

- How to insert values in your database

- How to remove values in your database

- How to update records in your database

 

Probably in that order.

 

If you are still having problems, come back with some source code and I will be more than happy to help!

how is this solution?? tell me if there is another easier way than what i have done>

 

<?php

 

$sql = '';

// connect to the database

$conn = mysql_connect('localhost', 'root', '');

 

// select the hrms database

mysql_select_db('hrms', $conn);

 

// check whether the form submitted by invoking the cmdDelete button

if(isset($_GET['cmdDelete'])) {

 

// sql delete statement definition

$sql = "delete from Student where StdNo = " . $_GET['txtStdNo'];

 

// check whether the form submitted by invoking the cmdUpdate button

} else if(isset($_GET['cmdUpdate'])) {

 

// sql update statement

$sql = "update Student set Name = '" . $_GET['txtName'] . "', Address = '" . $_GET['txtAdd'] . "', ContactNo = '" . $_GET['txtTel'] . "' where StdNo = " . $_GET['txtStdNo'];

}

 

// execute the sql query

mysql_query($sql);

 

// close the connection

mysql_close($conn);

 

?>

i think what ur looking for is called mod_rewrite.

i dont have time to give u the link but im sure youl rather enjoy this function. i used it once when i was reworking a tutroail and it really mae a lott of sense. perhaps u need to strighten otutthings with the mods of ur site before uget into this mod_rewrite kind of stuff just on a personal note just incase u fail at understanding my pisy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.