Hi

I have some code where the user inputs some stuff and then i would like it to get added to a database. The problem is dont know how to make it so that it only adds to the database when the user has submited it?

Any ideas ?

Hi newbie 123 and welcome to daniweb

All you need to do is use $_POST to test if the form has been set in the URL.

This would be your form:

<form action='?send=true' method='POST'>
<input type='text' name='whatever'>
</form>

When this form is clicked the user is sent to the same page but

?send=true

is echoed in the URL.

You can then test if it is set by doing the following:

if (isset ($_POST['send'])) {
// SEND OF TO DATABASE
}

Hope all this helps
And if you need any help just post :)

That works great thankyou !!!!
Daniweb seems great and it was such a fast reply :O

Thankyou thankyou thankyou !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.