help how to make add form

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
php9
New php-forum User
New php-forum User
Posts: 13
Joined: Fri Feb 22, 2013 2:20 am

Fri Feb 22, 2013 2:24 am

An option is to keep the user on the same page. So your form is shown by insert.php and it also submits to insert.php. By check if the form is submitted you can do the insert, show a message and let the page show the form as it would do if there was no submission (ie first page view).

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Wed Mar 13, 2013 8:34 am

php9 wrote:An option is to keep the user on the same page. So your form is shown by insert.php and it also submits to insert.php. By check if the form is submitted you can do the insert, show a message and let the page show the form as it would do if there was no submission (ie first page view).
yes, you can tell if you're responding to a form by just verifying $_POST...

Code: Select all

if ($_POST) { //responding to form
...
} else { //display form
...
}
but technically even though it's redirecting to itself, the visitor is still leaving the page. If you wanted to really keep the user on the same page, you would have to use something like ajax to interact with the database. w3schools has a lot of primers and lessons on ajax at http://www.w3schools.com/ajax/default.asp that should be able to get you going in no time.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests