Jump to content

php mysql entering data in database - does not post to db


Recommended Posts

I am having a little problem with my php page I have a simple area to icert data - only it does not incert the data. I have not encountered this before. I cannot see anything wrong with it but, maybe someone else can. connection to the database is already made at this point at the top of my page. It does connect and the date is entered but nothing else?

Here is the code:

 

<?php

if (isset($_REQUEST['Submit']))

{

$date = date("Y-m-d");

$sql = "INSERT INTO ads(heading, body, date, author_name, author_email, link) VALUES('$heading', '$body', '$date', '$author_name', '$author_email', '$link')";

if($result = mysql_query($sql ,$db))

{

echo "Thank you, Your information has been entered into our database";

}

else

{

echo "ERROR: ".mysql_error();

}

 

}

else

{

 

?>

<p><h3>Enter your ad into the database</h3>

<form  method="post" action="test4.php">

Name:     <input type="text" size="20" name="author_name"><p>

Email:      <input type="text" size="20" name="author_email"><p>

Heading:  <input type="text" size="20" name="heading"><p>

Description:<br>

<textarea cols=40 rows=10 name="body" wrap="virtual">

</textarea><p>

Full Link:  <input type="text" size="50" name="link"><p>

<input type="submit" name="Submit" value="Submit Ad!">

</form>

<?php

}

?>

 

thanks for everyone's help!

I kinda thought somthing like that but I am REQUESTING not POST

 

I get this

 

Fatal error: Function name must be a string in /home/srppur3/public_html/srp-design/test4.php on line 121

 

I entered this:

 

$heading = $_POST(heading);

$heading = mysql_real_escape_string(strip_tags($_REQUEST['heading']));

 

This is what I use for added security, Sorry, I overread the Request part.

 

All your variables have to be set if you are going to put them in the database.

 

Ok every thing is working fine now! I have another question if possable.

this page is on my web site - and they have to pay to fill that out.

How would you go about making it so the page cannot be accessed directly?

They will not be a member or anything and i dont want them to be.

Basically they go to a paypal page first and after payment they get to fill in the info.

But you can access the page directly if you know the address..

 

Thanks Again

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.