close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Help with Registration Page

Thread began 10/15/2009 3:38 pm by buonsen368464 | Last modified 10/22/2009 1:32 pm by Jason Byrnes | 5239 views | 17 replies |

buonsen368464

Help with Registration Page

Hello Support,
I am using SA and generated the following:
registration page, login page, Email Password page, Profile and logout page.
Uploaded the pages and tested the registration page by completing the necessary information and after I clicked submit button, I was redirected to HTTP 404 Webpage cannot be found.
I was expecting to be redirected to the login page. Any help? I appreciate your kind effort

<?php require_once('../Connections/Roseshuttle.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="../account/failed.php";
$loginUsername = $_POST['EmailAddress'];
$LoginRS__query = "SELECT EmailAddress FROM user WHERE EmailAddress='" . $loginUsername . "'";
mysql_select_db($database_Roseshuttle, $Roseshuttle);
$LoginRS=mysql_query($LoginRS__query, $Roseshuttle) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

?>
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "WAATKRegistrationForm")) {
$insertSQL = sprintf("INSERT INTO user (UserName, Password, ConfirmPassword, FirstName, LastName, PhoneNumber, StreetAddress, City, State, Zipcode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['UserName'], "text"), GetSQLValueString($_POST['Password'], "text"), GetSQLValueString($_POST['ConfirmPassword'], "text"), GetSQLValueString($_POST['FirstName'], "text"), GetSQLValueString($_POST['LastName'], "text"), GetSQLValueString($_POST['PhoneNumber'], "text"), GetSQLValueString($_POST['StreetAddress'], "text"), GetSQLValueString($_POST['City'], "text"), GetSQLValueString($_POST['State'], "text"), GetSQLValueString($_POST['Zipcode'], "text"));

mysql_select_db($database_Roseshuttle, $Roseshuttle);
$Result1 = mysql_query($insertSQL, $Roseshuttle) or die(mysql_error());

$insertGoTo = "../account/user_LogIn.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>

Sign in to reply to this post

neilo

"../account/failed.php"
"../account/user_LogIn.php"

The above paths mentioned in your registration page code suggest that your registration page is not in the root directory. If it were, they would be:

"account/failed.php"
"account/user_LogIn.php"

Could you provide a link for the pros here to have a look at the page to see what the problem is?

Sign in to reply to this post

anonymous

You may want to try root relative links for your redirects instead.

So change this: $insertGoTo = "../account/user_LogIn.php";

To this: $insertGoTo = "/account/user_LogIn.php";

By doing that it sets the link absolutely from root... rather relative to the document if your problem is in fact being caused by a path error.

Do you have a link to the URL where I could test it? I will try to register and see what happens to see if i can tell what's going on, if there is another issue.

Cheers,

Brian

Sign in to reply to this post

buonsen368464

Help with Registration Form

Hello Neilo & Brian,
Appreciate your prompt responses. I have changed what Brian proposed and the result reminds the same.

Below is the link to the testing Registration form

user_Registration.php

Thanks you all

Sign in to reply to this post

neilo

Your registration page and user login pages are in the directory 'account', and the failed.php page appears to be in the root directory. The form action is to the registration page itself.

So I would assume that the form action should be:

<form action="user_Registration.php?"

and the following lines should be:

$MM_dupKeyRedirect="../failed.php";

$insertGoTo = "user_LogIn.php";

May be worth a try?

Sign in to reply to this post

Jason ByrnesWebAssist

neilo is correct, the problem is in the code for checking if the username already exists:

php:
<?php

// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset(
$_POST[$MM_flag])) {
$MM_dupKeyRedirect="../account/failed.php";
$loginUsername $_POST['EmailAddress'];
$LoginRS__query "SELECT EmailAddress FROM user WHERE EmailAddress='" $loginUsername "'";
mysql_select_db($database_Roseshuttle$Roseshuttle);
$LoginRS=mysql_query($LoginRS__query$Roseshuttle) or die(mysql_error());
$loginFoundUser mysql_num_rows($LoginRS);




The redirect:
$MM_dupKeyRedirect="../account/failed.php";

ends up pointing to:
failed.php

but the failed.php page exists at:
failed.php


The redirect needs to be changed to:
$MM_dupKeyRedirect="../failed.php";


The cause of the failure is a different matter. In the Users table, you have a record where the user name is blank.

Additionally, you changed the name of the UserName form element from "EmailAddress" to "UserName".


When a user attempts to register, the duplicate username code is using the original name for the userName form element to look for duplicates:
$loginUsername = $_POST['EmailAddress'];


since this for element no longer exists, the value it is looking for is blank ("")

Change:
$loginUsername = $_POST['EmailAddress'];

to:
$loginUsername = $_POST['UserName'];


so it will use the correct form element when looking for duplicate usernames:<td width="160"><input class="WAATKTextField" name="UserName" id="UserName" value="" size="25" type="text"></td>

Sign in to reply to this post

buonsen368464

Help with Registration Form

Neilo & Brian,
I just want to thank you for your prompt feedbacks. You guys are doing an amazing job.
I don't know what I am doing wrong. First when I filled out the registration page, I expect it to redirect me to login, but instead, it redirects me to failed.php page despite the fact that the email address(username) had not been previously used in the registration form. I expect to be redirected to failed.php if my email address(username) is already been used in the registration process

Secondly when I login into myphpAdmin and check on my database, no information is found on my database table.

I decided to regenerate another pages using SA and tried to complete the registration form and it still redirected me to registered.php page eventhough my email address(username) was not duplicate in the database. And worse still no information was sent to the database.

Also my profile page seems to have not form as it is expected. Below is the link to newly generated testing page

user_Registration.php

Please I don't know what I am doing wrong. Any help?
Thanks in advance

Sign in to reply to this post

neilo

Hi buonsen,

With this one - as the form action is set to the user_Registration.php page (i.e. itself) where you have:

<form action="/Templates/user_Registration.php?"

should really be

<form action="user_Registration.php?"

I can't complete the form at the time of this posting- as the 'State' dropdown list isn't populated, so returns an error. Assuming that the other paths are correct (error & success, WA files) changing the line above should take you forward a bit.

Perhaps you could change the above line - for the purposes of testing this example - and put some values in the 'State' selector so someone can have another look at it?

This suggested in preparation for Jason sorting out the clever stuff.

Sign in to reply to this post

buonsen368464

Help with Registration Form

Hi Support Team,
The registration form seems to ok after the corrections were made, but after completing the form field information, and hitting the submit button, no information seem to be inserted(submitted) to the database. I tried several times with diferent usernames and it kept redirecting me to registered.php page. I thought it will redirect user to registered.php page if the user had previously registered to avoid repeated registration.

Secondly Email password page is not working either. I don't no what I am doing wrong. Any help please?
Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Please compress you pages into a zip archive and attach the zip file to your replay so I can look at the code.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...