Jump to content

Recommended Posts

Posted

Hi

Can anyone please show me how i can make a page in dreamwever, where a user can enter information, store it on the SQL database and then another page which shows the information?

Many Thanks

chris

Posted

The basic idea is to create a form

<form method="post" action="yourfile.php">
<input type="text" name="ur_name"/>
<!-- some more input fields here -->
<input type="submit" name="submit" value="Submit Form!"/>
</form>

and then inside yourfile.php do something like

<?php
$name=mysql_escape_string($_POST['ur_name'];
//and same goes for other fields
if( some verification you want here) {
mysql_query("INSERT INTO TABLE_NAME (name, and other values separated by , ) values ('$name')");
}else{
//do something else
}
?>

To display the info:

<?php
$query = mysql_query("SELECT * FROM users");
$count = mysql_num_rows($query);
$smth=mysql_fetch_array($query);
if ( $count > 0 ) {

  echo $smth['name']
  //and other from array
} else {
echo "no data can be retrieved for specifed conditions or smth like that"; }
?>

Bare in mind that I wrote this in 3mins and that this is not completely correct way of doing things and it can be prone to a lot of hacks. This is just to give you a basic idea on how to do things. Check W3 schools to see how to INSERT, GET, DELETE, CHANGE etc. stuff from a MySQL database using PHP.

Hope this helps you out a bit.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...