again my php problems continue.
phpinfo() works, testing connections to mysql works, phpmyadmin lets me create mysql databases fine.
My IE displays my php pages now, like thios simple guestbook below.
BUT what it does is when i submit the form i get nothing, the fields clear themselfs but know new page, no data record is added to my database. My cookies dont work either - pre done forums iv placed in do the same, they appear, i can input data but nothing comes of it.
PLEASE SOMEONE HELP I NEED THIS UP AND RUNNING AND IM SPENDING TO LONG ON A SIMPLE FIX I BET.
thanks :wink:
<html>
<head>
<title>sign the guestbook</title>
</head>
<body>
<?php
$form = "<form action=\"$PHP_SELF\" method=\"post\">";
$form.= "Name: <input type=\"text\" name=\"name\" ";
$form.= "size=\"25\" value=\"$name\"> <br>";
$form.= "comments:<br>";
$form.= "<textarea name=\"comments\" cols\"45\" ";
$form.= "rows=\"4\">$comments</textarea> <br>";
$form.= "<input type=\"submit\" name\"submit\" ";
$form.= "value=\"sign\"> </form>";
if( !$$submit) { $msg = $form; } else
if( !$name or !$comments)
{ $msg = "<b>Please complete all the fields</b><br><br>";
$msg.=$form;
}
else
{
$conn = @mysql_connect("localhost", "liam", "lions20")
or die("could not connect to database");
$rs = @mysql_select_db("members",$conn)
or die ("could not select to that database");
if($name and $comments)
{
$sql="insert into guestbook (name, comments)
values (\"$name\",\"$comments\")";
$rs = @mysql_query($sql,$conn)
or die ("could not execute sql query");
}
if($rs)
{
$msg = "<h3>Thankyou - your entry has been saved.";
$msg.= "<br><a href = \"guestbook-view.php\">";
$msg.="View My Guestbook</a></h3>";
}
}
echo($msg);
?>
</body>
</html>
[--- cookie----]
<?php
if( ($user != null) and ($colour != null) )
{
setcookie( "firstname", $user, 0 );
setcookie( "fontcolour", $colour, 0 );
header("Location:getcookie.php" );
exit();
}
?>
<html>
<head>
<title>cookie test</title>
</head>
<body>
<form action="<?php echo($PHP_SELF); ?>" method="post">
please enter our first name
<input type="text" name="user"> <br> <br>
please choose yiur favourite font colour: <br>
<input type="radio" name="colour" value = "#FF0000">red
<input type="radio" name="colour" value = "#00FF00">Green
<input type="radio" name="colour" value = "#0000FF">Blue
<br> <br> <input type="submit" value="submit">
</form>
</body>
</html>
test them to see if they work on your set up


