Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/87371-php-shoutbox/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87371-php-shoutbox/#findComment-446934
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.