0

Hi!
I have a form working and in the login section I also give the option to register in case someone hasnt done so yet. This will show another form which, on submit, will use a different .php page.

Now on that page,if register is successful, I'd like it to change a field value on the initial page but I haven't been able to do so. It would be basically taking a field off from hiding and displaying a message for user feedback letting him know it worked.

I have tried this

function conf($fld,$message) {
	echo '<script language=\'JavaScript\' type=\'text/JavaScript\'>
        	var field = document.getElementById("'.$fld.'");
			field.value = "'.$message.'";
          </script>';
	}

(...)

if($result) {
		header("location: ../Llog.php");
		conf('msg',"You have been successfully registered but you will need admin approval");
		exit();
	}else {
		die("Query failed");
	}

but has expected as soon as it changes page it doesn't do anything else that follows.
Should I do something like header("location: ../Llog.php?id=1"); and make a catch on that? I dont really like those sort of solutions but cant think of anything else, hopefully is just me not being able to look outside the box

Thanks for reading

Edited by Auch: typo hunting

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Auch
0

Hi!
I have a form working and in the login section I also give the option to register in case someone hasnt done so yet. This will show another form which, on submit, will use a different .php page.

Now on that page,if register is successful, I'd like it to change a field value on the initial page but I haven't been able to do so. It would be basically taking a field off from hiding and displaying a message for user feedback letting him know it worked.

I have tried this

function conf($fld,$message) {
	echo '<script language=\'JavaScript\' type=\'text/JavaScript\'>
        	var field = document.getElementById("'.$fld.'");
			field.value = "'.$message.'";
          </script>';
	}

(...)

if($result) {
		header("location: ../Llog.php");
		conf('msg',"You have been successfully registered but you will need admin approval");
		exit();
	}else {
		die("Query failed");
	}

but has expected as soon as it changes page it doesn't do anything else that follows.
Should I do something like header("location: ../Llog.php?id=1"); and make a catch on that? I dont really like those sort of solutions but cant think of anything else, hopefully is just me not being able to look outside the box

Thanks for reading

header("Location: some_page.php");

Is actually a very good solution, and there is a good reason it is used. That is to make sure the refresh button does not resubmit the form.

Example:

form.php
---> submit
process.php
----> redirect using header("location...
done.php

If the user now clicks refresh, it only refreshes done.php. Which just displays a message, and nothing else.

If the user clicks the back button, they are taken to form.php, skipping process.php

So if you want to go back to the initial page, just redirect to it with header("location...

Add a parameter to the URL, to track the changes. eg:

header("Location: form.php?status=been_here_before");

So you want then get that via:

$_GET['status']

and know to change something on that page.

0

Yes Im working on that now, I was just hoping someone would have an idea to not use that method, i dont really like changing the url and giving clues on whats going on :)

0

Interesting idea.
Will check into that, thanks for the tip

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.