Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

php - not working - yet its et up right, i think

General discussions related to php

Moderators: macek, egami, gesf

php - not working - yet its et up right, i think

Postby nexus14 » Sun Feb 09, 2003 4:19 pm

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
nexus14
New php-forum User
New php-forum User
 
Posts: 3
Joined: Fri Feb 07, 2003 3:55 pm
Location: leicester

Postby Redcircle » Mon Feb 10, 2003 12:19 am

Most likely is in your php.ini you have register_globals turned off which is essentially a good thing. But it make it a lil trickier. mainly because most php books and sites have tutorials written with the assumption that register_globals is turned on by default which it was until version 4.2 so mosy people it didn't matter. BUT to be more secure you have to use a different method to get the same results.


Here is the doc page to give you some more information.
http://www.php.net/manual/sl/reserved.variables.php

Like I said. most likely this is the problem but not for sure.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby nexus14 » Mon Feb 10, 2003 12:36 am

ok so i can turn them on to get this code working but what about when i import pre-written code i have obtained, they dont work either. I have thought it could be in the php.ini or apache config file, but what?
What possible elements need to be changed that i havent done allready?
:oops:
The dlls? - i have copied two the one straight from the php folder and one (apache2) from the aspi folder. I have apache2 so thats right, is there any others?
Can anyone post there php.ini, or apache config file for me to check through - obviosly removing any security info from it.
thanks
nexus14
New php-forum User
New php-forum User
 
Posts: 3
Joined: Fri Feb 07, 2003 3:55 pm
Location: leicester

Postby Redcircle » Mon Feb 10, 2003 12:42 am

apache2 is not 100% working in all aspects of PHP or MySQL. I would suggest using apache 1.3.27
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP General

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron