Jump to content

Loading a HTML page after php entry.


pluto

Recommended Posts

Dear all,

 

I've managed to do the bits I've wanted in terms of adding words to data bases, and ensuring that they don't exist etc.  However, I've come across an interesting problem.

 

Ideally, I'd like the screen to go back to the HTML input form once a record has been added, but I can't seem to work out how to do that.

 

I've read about URLREFERER or something like that somewhere, but I was wondering if anyone had other ideas?

 

Many thanks

 

Pluto

Link to comment
Share on other sites

Alas,

 

When I tried the header, I got the following error:

 

word exists

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\insert_word.php:9) in C:\xampp\htdocs\insert_word.php on line 11

 

This is my code...

 

<?php
    // Open the data base connection
    $conn = mysql_connect("localhost","root","");
    mysql_select_db("test",$conn);
    // check that the word exists first.
    $check = "SELECT * FROM TEST2 where word = '$_POST[word]";
    if($check==true)
    {
        echo "word exists";
        // load the previous page again
        header('Location:http://localhost/insert_test.html');
        exit;
      
    }
    else
    {
        $sql = "INSERT INTO test2 values ('','$_POST[word]','$_POST[definition]','$_POST[chapter]','$_POST[section]')";
        if(mysql_query($sql, $conn))
        {
            // check that the word doesn't already exists
            echo "record added";
      
        }
        else
        {
            echo "Error in entering the record";
        }
    }
?>

 

Ideally, I'd like the warning to come in red under the text box in the HTML page, but that'll come with further practice I'm sure, and that's a different issue.

 

Thanks in advance

 

Pluto

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.