PDA

View Full Version : Trying to add dynamic data.... need help


mzgunn
04-13-2007, 03:09 AM
I have a registration page and I want to make sure that the same username is not picked by 2 different people so I did the "check username" feature under the "servers behavior" section in DW.

So, I have a page set up that says "The username (blank) already exists, please go back and blah blah..." So, in the blank I'm trying to make the already taken username that the person types in show up... but for some reason I can't get it to work. It just shows the same name each time. I know this is fairly simple, but I'm just not getting it, so any help would be great.

Thanks.

davidj
04-13-2007, 05:43 AM
i dont know how to do this in dreamweaver but i do know how to code this in PHP

i can help only if you want to learn PHP

?

edbr
04-13-2007, 07:49 AM
y not post your code as a place to start

mzgunn
04-13-2007, 02:11 PM
<?php require_once('Connections/myconnection.php'); ?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="userexists.php";
$loginUsername = $_POST['Username'];
$LoginRS__query = "SELECT Username FROM Login WHERE Username='" . $loginUsername . "'";
mysql_select_db($database_myconnection, $myconnection);
$LoginRS=mysql_query($LoginRS__query, $myconnection) 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;
}
}

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO Login (Username, Password, Firstname, Lastname, Emailaddress, `Admin`, Allowed, UsertypeID) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Username'], "text"),
GetSQLValueString($_POST['Password'], "text"),
GetSQLValueString($_POST['Firstname'], "text"),
GetSQLValueString($_POST['Lastname'], "text"),
GetSQLValueString($_POST['Emailaddress'], "text"),
GetSQLValueString($_POST['Admin'], "int"),
GetSQLValueString($_POST['Allowed'], "int"),
GetSQLValueString($_POST['UsertypeID'], "int"));

mysql_select_db($database_myconnection, $myconnection);
$Result1 = mysql_query($insertSQL, $myconnection) or die(mysql_error());
}
?>
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}

if (isset($_POST['Username'])) {
$loginUsername=$_POST['Username'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "welcome.php";
$MM_redirectLoginFailed = "nologin.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_myconnection, $myconnection);

$LoginRS__query=sprintf("SELECT Username, Password FROM Login WHERE Username='%s' AND Password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $myconnection) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;

//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Getting Started</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url();
background-color: #FFFFFF;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #666666;
}
.style2 {color: #666666}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style></head>

<body>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="Pprofiles_01.jpg" width="900" height="144"></td>
</tr>
</table>
<h3 class="style1">&nbsp;</h3>
<h3 class="style1">Registration for Picture Profiles </h3>
<p>
<form action="<?php echo $editFormAction; ?>" method="post" name="register" id="register">
<table align="left">
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td><input type="text" name="Username" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td><input type="password" name="Password" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">First name:</td>
<td><input type="text" name="Firstname" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Last name:</td>
<td><input type="text" name="Lastname" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">E-mail address:</td>
<td><input type="text" name="Emailaddress" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Register"></td>
</tr>
</table>
<input type="hidden" name="Admin" value="0">
<input type="hidden" name="Allowed" value="1">
<input type="hidden" name="UsertypeID" value="2">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><span class="style3">*all fields are required to register </span></td>
</tr>
</table>
<p class="style3">&nbsp;</p>
<p>&nbsp;</p>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><span class="style3">Already a member?</span></td>
</tr>
</table>
<p class="style3">&nbsp;</p>
<h3 class="style2 style3">Login</h3>
<blockquote>
<form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="formlogin" id="formlogin">
<table border="0" align="left" cellpadding="2" cellspacing="0">
<tr>
<td><label for="Username">Username:</label></td>
<td>
<label for="Username"></label>
<input type="text" name="Username"></td>
</tr>
<tr>
<td><label for= "Password">Password:</label></td>
<td>
<label for= "Password"></label>
<input type="password" name="Password"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">
<input type="submit" name="Submit" value="Login">
</div></td>
</tr>
</table>
</form>
</blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

mzgunn
04-14-2007, 01:41 PM
nothing???

davidj
04-14-2007, 05:25 PM
do you want to learn PHP so you understand what it all means
do you want someone to sort that code you postedlet me know what you want

mzgunn
04-14-2007, 06:08 PM
I'd rather learn it, if that's at all possible within this forum....

davidj
04-14-2007, 06:20 PM
GREAT

correct answer

i will give you my time but in return you have to give the same commitment

you will walk away with PHP on your CV and this is FREE

start here then come back...

http://www.dreamweaverclub.com/vtm/php-mysql-apache.php

mzgunn
04-15-2007, 03:34 AM
ok. no problem. thanks.