fm1 Posted January 23, 2008 Share Posted January 23, 2008 Heres my code <? //the host, name, and password for your mysql mysql_connect("localhost","fawaaz","honda"); //select the database mysql_select_db("news"); if($submit) { //use the PHP date function for the time $time=date("h:ia d/j/y"); // inserting it into the shoutbox table which we made in the mysql statements before $result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)". "VALUES ('NULL','$name', '$message','$time')"); } ?> <? //returning the last 5 messages $result = mysql_query("select * from shoutbox order by id desc limit 5"); //the while loop while($r=mysql_fetch_array($result)) { //getting each variable from the table $time=$r["time"]; $id=$r["id"]; $message=$r["message"]; $name=$r["name"]; ?> <? echo $time ?><br> <? echo $name ?><br> <? echo $message ?><br> <? } ?> <form action="<? echo $php_self ?>" method="post"> <INPUT TYPE='TEXT' value='name' NAME='name' SIZE=30 maxlength='100'><br> <INPUT TYPE='TEXT' value='message' NAME='message' SIZE=30 maxlength='100'> <input type="submit" name="submit" value="submit"> </form> my problem, create database already, when opening script in browser opens fine, but as soon as you fill in the name and comment and press submit,it returns back to the previous page,(like it refreshes),no data is displayed and no data is recorded in mysql Quote Link to comment https://forums.phpfreaks.com/topic/87371-php-shoutbox/ Share on other sites More sharing options...
adam291086 Posted January 23, 2008 Share Posted January 23, 2008 that is because you are not defining the variable $php_self if you want to send the form to itself and have the validation at the bottom just leave action like this adtion="" Quote Link to comment https://forums.phpfreaks.com/topic/87371-php-shoutbox/#findComment-446909 Share on other sites More sharing options...
rajivgonsalves Posted January 23, 2008 Share Posted January 23, 2008 are your register_globals setting on or off, if its off this script will never work.. Quote Link to comment https://forums.phpfreaks.com/topic/87371-php-shoutbox/#findComment-446910 Share on other sites More sharing options...
beebum Posted January 23, 2008 Share Posted January 23, 2008 Try using this: <form action="{$_SERVER['PHP_SELF']}" method="post"> Quote Link to comment https://forums.phpfreaks.com/topic/87371-php-shoutbox/#findComment-446916 Share on other sites More sharing options...
fm1 Posted January 23, 2008 Author Share Posted January 23, 2008 Try using this: <form action="{$_SERVER['PHP_SELF']}" method="post"> Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 localhost 01/23/08 16:07:42 Apache/2.2.6 (Win32) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.4 Quote Link to comment https://forums.phpfreaks.com/topic/87371-php-shoutbox/#findComment-446934 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.