Reply to Re: [PHP] Message check then post

Your name:

Reply:


Posted by disguised.jedi on 08/04/05 04:26

On 8/3/05, George B <geoizil@gmail.com> wrote:
> I am coding a message board. I am about done. I have all the forms
> needed for the message. So it all works out. The user types in his name,
> message title, and the message itself. Then clicks submit. The Submit
> button takes him to the message check. The message check shows all the
> stuff the user entered. Then it has "echo" which says 'Is this correct'?
> And then there is a button. "Yes" When the user clicks yes it goes to
> another PHP file which runs the SQL query to put in the entereddata into
> the database
> $query = "INSERT INTO forum (user,name,message) VALUES
> ('$username','$name','$message')";
> $result = mysql_query($query);
>
> But see, the problem is that it is entering blanks into the DB. I think
> that is because the $username $name and $message are in the other file?
> I have no idea how to by-pass this problem. What should I do?
Use hidden form values. You have displayed the data along with your
"is this OK?" message, so in that file, do this...

<form name="message" action="see [1] below" method="post">
<input type="hidden" name="user" value="<?php echo $username; ?>">
<input type="hidden" name="name" value="<?php echo $name; ?>">
<input type="hidden" name="message" value="<?php echo $message; ?>">

The "Is this OK?" stuff goes here.

<input type="submit" value="Yes, post it!">
<input type="button" value="No, take me back!"
onClick="window.location.href='see[2] below'">
</form>

[1] - The page with the database code goes here.
[2] - The previous page goes here.

This will stick the form values back inside a form which will be
posted to the next page. The user can't see or edit them. Hidden
form values are very useful, I'd recommend you take a closer look at
them!

Hope that helps!

--
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored.
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация