Forums

This topic is locked

Check new username & redirect

Posted 20 Feb 2007 01:13:23
1
has voted
20 Feb 2007 01:13:23 rob hewitt posted:
i'm using DMX 8.02, MySQL 5.0.21 & PHP

i have a user registration page in my site - called registerfree.php - i've used the built in 'check new username' function in dreamweaver to make sure username is unique - this redirects to any page i choose if the user trys to use a username already created.

my problem is how do i inform the user the username is already in use then redirect them back to the registration page where the details they input remain & all they have to change is the username.

if i redirect back to registerfree.php the form is empty. if i redirect to an error page then use a javascript link to go back to registerfree.php it says the form has expired.

the registration form has 16 fields to fill in & it seems a waste of time having to re-enter their details.

Any ideas?

Replies

Replied 20 Feb 2007 19:17:08
20 Feb 2007 19:17:08 Alan C replied:
HI
This is one way to tackle it - make your registration page so that it does the error checking on the server when the submit button is pressed, then if there is an error redirect back to itself, on entry you can test the $_POST array to determine whether you have arrived from the submit button or an error condition. You can store the error conditions in a session if you have one going.

As for populating the text fields in your form . . . this is how I do it for items that are already in a database

<pre id=code><font face=courier size=2 id=code>
&lt;tr &gt;
&lt;td width="220" align="right"&gt;second line of address&lt;/td&gt;
&lt;td width="250" &gt;&lt;input type="text" name="p_address_2" value="&lt;?php echo $row_rsPropertyUpdate['p_address_2']; ?&gt;" size="32" /&gt;&lt;/td&gt;
&lt;/tr&gt;
</font id=code></pre id=code>


you can preserve them in the $_POST array by sending them back to the form, it starts to get messy at this stage.

There is a complete login system with coding for error handling here

evolt.org/node/60384

have a look at the way form.php handles errors

Reply to this topic