Jump to content

Need help coding a web form


derekbelcher

Recommended Posts

Is this right?  how do I list the inputs?  Sorry, so many questions, I am very novice at PHP, trying to learn though :-)

<?php

  if ($HTTP_POST_VARS['submit']) {

    mysql_connect("server info");

    mysql_select_db("server info");

    $entrytitle=$HTTP_POST_VARS['entrytitle'];

    $entrytext=$HTTP_POST_VARS['entrytext'];

    $query ="INSERT INTO weblog (entrytitle,entrytext)";

    $query.=" VALUES ('$entrytitle','$entrytext')";

if(isset($_POST['preview'])) {

    echo "Here is your preview: ";

 

    $result=mysql_query($query);

    if ($result) echo "<b>Successfully Posted!</b>";

    else echo "<b>ERROR: unable to post.</b>";

  }

?>

<?php

//Your form goes here..

if(isset($_POST['preview'])) {
echo "Here is a preview";
//Output the variables they filled in..
echo $title;
echo $weblog_entry;
}

?>

 

Replace the variables with whatever variables you're using. It's not as hard as it seems. You just take the variables they've filled in, and then output them on the same page IF they've pressed "preview".

 

EDIT: what maq said.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.