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>";

  }

?>

Link to comment
Share on other sites

<?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.

Link to comment
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.