Click to See Complete Forum and Search --> : need help


cool_keno
09-21-2005, 10:24 AM
Hi,i need help.I want to make a guestbook.But the design is under html,form action use php.When i click the submit button.It will proccess the php files,then when the data had inserted to myqsl it will redirect to thanks.html.And maybe send an email to the person who has sign the guestbook.Please help me.I really need it.Thanks a lot guys.

bokeh
09-21-2005, 12:31 PM
I guess from your post you want someone to make the script for you. If that is so try having a look on www.hotscripts.com

cool_keno
09-22-2005, 11:15 PM
I've wrote the scripts.I need help to check the scripts i've wrote.

->guestbook.html

<html>
<head>
<title>Guestbook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="post" name="guest" action="guest.php" >
<table width="550" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="100">Name *</td>
<td>
<input name="txtName" type="text" id="txtName" size="30" maxlength="30"></td>
</tr>
<tr>
<td width="100">Email</td>
<td>
<input name="txtEmail" type="text" id="txtEmail" size="30" maxlength="50"></td>
</tr>
<tr>
<td width="100">Website URL</td>
<td>
<input name="txtUrl" type="text" id="txtUrl" value="http://" size="30" maxlength="50"></td>
</tr>
<tr>
<td width="100">Message *</td> <td>
<textarea name="mtxMessage" cols="80" rows="5" id="mtxMessage"></textarea></td>
</tr>
<tr>
<td width="100">&nbsp;</td>
<td> <div align="center">
<input name="submit" type="image" src="btsign.gif" width="101" height="22" border="0">
<input name="reset" type="image" id="reset" src="btreset.gif" width="101" height="22" border="0">
</div>
</td>
</tr>
</table>

</form>
</body>
</html>

-> guest.php
<?php

$conn = @mysql_pconnect('localhost','gb','password' ) or die ('Error connecting to mysql');

mysql_select_db('gb');





if(isset($_POST['submit']))

{



$name = trim($_POST['txtName']);

$email = trim($_POST['txtEmail']);

$url = trim($_POST['txtUrl']);

$message = trim($_POST['mtxMessage']);





if(!get_magic_quotes_gpc())

{

$name = addslashes($name);

$message = addslashes($message);

}





if ($url == 'http://')

{

$url = '';

}





$query = "INSERT INTO guestbook (name, email, url, message, entry_date) " .

"VALUES ('$name', '$email', '$url', '$message', current_date)";





mysql_query($query) or die('Error, query failed. ' . mysql_error());



header('Location:thanks.html');





exit;

}

?>



Please help.Thanks a lot

bokeh
09-23-2005, 01:49 AM
So... What problem are you having?

Sheldon
09-23-2005, 02:35 AM
Tell us as much as you can and please please please post your code in tags ie...
[ php ] code... [ /php ]


Thanks

EDIT: Done by Stephen Philbin

cool_keno
09-25-2005, 10:33 AM
When i click the sign button,it goes to the php page but doesn't execute the php tags.I mean if it works it should redirect to the thanks.html.But it stops at the the php page.Please help to configure the php script.Thanks a lot.

cool_keno
09-25-2005, 10:37 AM
the guest.php scripts i wrote

<?php

$conn = @mysql_pconnect('localhost','gb','password' ) or die ('Error connecting to mysql');

mysql_select_db('gb');

if(isset($_POST['submit']))

{
$name = trim($_POST['txtName']);
$email = trim($_POST['txtEmail']);
$url = trim($_POST['txtUrl']);
$message = trim($_POST['mtxMessage']);

if(!get_magic_quotes_gpc())
{
$name = addslashes($name);
$message = addslashes($message);
}

if ($url == 'http://')
{
$url = '';
}
$query = "INSERT INTO guestbook (name, email, url, message, entry_date) " .
"VALUES ('$name', '$email', '$url', '$message', current_date)";

mysql_query($query) or die('Error, query failed. ' . mysql_error());

header('Location:thanks.html');

exit;
}
?>

bokeh
09-25-2005, 11:35 AM
Are the files saved with .php extentions? When you test the code with a browser is 'http;//' displayed in the address bar?

Sheldon
09-25-2005, 04:06 PM
Is it adding the information to your database??
run this script to see if your databse is being updated.


<?php

$conn = @mysql_pconnect('localhost','gb','password' ) or die ('Error connecting to mysql');

mysql_select_db('gb');

$test = "SELECT * FROM guestbook SORT by ASC"; //SELECT ALL USERS FROM DATABASE
$test = mysql_query($test);

//WHILE USERS ARE IN THE DATABASE DO THE FOLLOWING
while($result = mysql_fetch_assoc($TEST)) {

//PRINT INFORMATION
echo("ID:{$result['id']} -
Name:{$result['name']} -
Email:{$result['email']} -
Url:{$result['url']} -
Message:{$result['message']} -
Date:{$result['entry_date']} ";
}
?>

cool_keno
09-27-2005, 04:30 AM
I want the data that the visitor give posted to mysql database.When i execute the guestbook.html,it display normally.When i click the sign button,it call the guest.php.But the php files does not execute the script i wrote.And when the scripts are executed,it will goes to thanks.html.Thanks a lot.

Sheldon
09-27-2005, 01:58 PM
I assume that your server supports PHP? If when you submit the page now it updates, thats good, but if when you submit the page and it loads the php page and shows all the tags and does not exicute te script then that means you do not have php support.

Search the php forum for freee php hosts and you will find a couple of threads posting good free php servers

cool_keno
10-01-2005, 04:48 AM
If i combine the guestbook.html and the guest,php and save it as a php files,it works normally.But if i separate it,the guest.php doesn't show the scripts,instead a blank page.I'm really confuse.Please help me.