473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

how can we deal with the database entry on the page refreshment

Hi I am having a web form which on submit is entering the data in the database.

Now if the page is refreshed the data is entered in the database again. can any one help me on how to get it fixed..

i tried to check with the javascript and html page refreshes. but i am not getting on how to work with it.

any help is appreciated
Jul 3 '08 #1
9 1950
realin
254 100+
Hi I am having a web form which on submit is entering the data in the database.

Now if the page is refreshed the data is entered in the database again. can any one help me on how to get it fixed..

i tried to check with the javascript and html page refreshes. but i am not getting on how to work with it.

any help is appreciated
hiya anubhavjha,

it is a common problem among new programmers. You have to make ur script in step wise. read below:

suppose data.php is your php file which submits entries to database, now when it submits your script should land onto an html page, where you have a javascript function which redirects to the actual page which you want to display after submission of data. This is very commonly seen on forums, when u just login and it says, wait for 5 seconds or click here if the browser doesn't redirects.

hope this helps
cheers !!
Jul 3 '08 #2
developing
110 100+
not sure what's the context of your needs but you can have an 'if' statement that checks the database for exisitng data before updating it.

or

you can have a session variable that is set to true when the database is updated. in your script, check the value of the variable. If it is false, update database. If it is true, don't update
Jul 3 '08 #3
Markus
6,050 Expert 4TB
You might unset() the post data once the DB is updated, then move the location to a new page.
Jul 3 '08 #4
pbmods
5,821 Expert 4TB
Heya, anubhavjha.

Once you have finished saving the new record, use a Location: header to redirect the browser (http://php.net/header).
Jul 4 '08 #5
dlite922
1,584 Expert 1GB
LOL @ refreshment

/sorry, just had to

Dan
Jul 4 '08 #6
Hi dear all,

Thank you for the valuable reply.

I have tried doing a header redirection but when i do that the variables that I have used in the $_session seems to be lost.

Also if we use the javascript function as when to redirect the page if it gets refreshed. can we use the post variables of the first page. I mean if let us say that there is a page1.php,page2.html and page3.php

page3.php will be loaded only if the page2 is not refreshed. will the values of page 1 be captured in the page3.

If you can give any more inputs on the page refreshment I will be thankful,

Regards,
Jul 7 '08 #7
hiya anubhavjha,

it is a common problem among new programmers. You have to make ur script in step wise. read below:

suppose data.php is your php file which submits entries to database, now when it submits your script should land onto an html page, where you have a javascript function which redirects to the actual page which you want to display after submission of data. This is very commonly seen on forums, when u just login and it says, wait for 5 seconds or click here if the browser doesn't redirects.

hope this helps
cheers !!
I am not able to understand this. sorry very much to say this but i am a learner in php now.
Jul 7 '08 #8
realin
254 100+
mate this one is simple..
say if you have page.php where u are manipulating the submitted values, then on page. php

[PHP]
/* here is the code where you need to write data manipulation or whatver u want
*
*
*
*/

//then after the data is submitted or you are done with what u wanted you can do

unset($_POST);
//or you can redirect using

header("Location:http://to-a-new-location.com");
[/PHP]

the above should do the trick.. i suppose.
any probs let me know
Jul 8 '08 #9
Markus
6,050 Expert 4TB
You could simply check if the data already exists in the database.
Jul 8 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
A very strange bug. www.monkeyclaus.org is run by a cms I'm developing. One of types of users we allow is "justTestingTheSite", a type of user I developed to give demo's to prospective clients. The...
9
by: Earl Partridge | last post by:
Windows XP, Frontpage 2000, IIS 5.1, Access 2000 When I attempt to open a connection to my database I get an error the page cannot be found... this on my local machine, using localhost. The page...
8
by: alamb200 | last post by:
Hi I have set up a SQL database to contain alist FAQ's for our company and then plan to pull this info off using a web page. So far I have entered the data but I am unable to control how it is...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
7
by: dubdave | last post by:
Hi I am trying to write a (very) basic script to compare data retrieved from a form with a mySQL database. In this case it is a simple name and password entry - if there is a corresponding entry...
4
by: so many sites so little time | last post by:
ok so i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have...
1
by: Eyadtrabulsi | last post by:
I have written code to creat .txt file then refreshing the information on the webpage to contain the content of the new generated file.. The page doesn't reflect the refreshment till the second...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
by: BibhuAshish | last post by:
hi, I have designed a jsp page. This jsp is able to auto refresh after 5 second. But i want after 5th times of auto refreshment the table present inside the body should change. Can anybody...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.