Jump to content

EXPERT HELP PLEASE!!


lukeawade

Recommended Posts

The PROBLEM is I need to display two different error messages based on the information in one textfield. If there is nothing in the textfield it shows an error based on the tNG_formvalidation(WORKS), the second error shows if their email already exists in the database(DOESNT WORK)

There is no error displayed using the code below. It just redirects to the next page(like its supposed to if there is an email in the textfield). The $database_connRegistration is set and works for everything else I'm doing.

 

Here is where i create the email error if its in the database already

<?php 
$colname_rsMail = "-1";
if (isset($_POST['email'])) {
   $colname_rsMail = $_POST['email'];

mysql_select_db($database_connRegistration, $connRegistration);
$query_email = sprintf("SELECT email FROM dashboard_registration WHERE email = '$email'");
$email = mysql_query($query_email, $connRegistration) or die(mysql_error());
$emailError = false;

if (mysql_num_rows($email)!== 0)
{
	$emailError = "That email address has already been registered.";
}
//Error exists, reformat values for repopulating fields
$email = stripslashes($email);
}?>

 

NOW how do I display that under the Textfield/Input when there is already an echo error??

<input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; echo $emailerror;?>" size="32" />
<?php echotNGs->displayFieldError("dashboard_registration", "email"); echo $emailError;?>

Link to comment
https://forums.phpfreaks.com/topic/124554-expert-help-please/
Share on other sites

You have "echo $emailerror" inside your input tag.  Is this on purpose?  You haven't showed the variable $emailerror (not same as $emailError).

 

"echo $emailError" is listed below, which should show "That email address has already been registered." if the email has been.  I don't see a redirect.  

 

"$email" is not defined when using it in your mysql query (unless you are still using PHP4 or less and your PHP settings allow you to do so).  You should really use $_POST['email']  

 

Seems that there is a lot of information that is missing that needs to be shown in order to fix your problem.  

 

 

Link to comment
https://forums.phpfreaks.com/topic/124554-expert-help-please/#findComment-643331
Share on other sites

i agree that there is some information missing, but i would guess it's because your query returns no rows.  that's because, as fanfavorite said, $email won't exist unless register_globals is on.  if you want a quick (and dirty) fix, change $email in the query to $colname_rsMail.

Link to comment
https://forums.phpfreaks.com/topic/124554-expert-help-please/#findComment-643334
Share on other sites

Here is what I just tried. Still does not work.

 

In The Precode

<?php
$colname_rsMail = "-1";
if (isset($_POST['email'])) {
   	$colname_rsMail = $_POST['email'];
mysql_select_db($database_connRegistration, $connRegistration);
$query_email = sprintf("SELECT email FROM dashboard_registration WHERE email = '$colname_rsMail'");
$email = mysql_query($query_email, $connRegistration) or die(mysql_error());
$emailError = false;

if (mysql_num_rows($email)!== 0)
{
	$emailError = "That email address has already been registered.";
}
//Error exists, reformat values for repopulating fields
$email = stripslashes($email);
}?>

 

In the Body

<input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email'];?>" size="32" />
<?php echo $emailError; echo $tNGs->displayFieldError("dashboard_registration", "email");?>

Link to comment
https://forums.phpfreaks.com/topic/124554-expert-help-please/#findComment-643342
Share on other sites

^ They might be the same im not sure... but also... what is sprintf? instead of

$query_email = sprintf("SELECT email FROM dashboard_registration WHERE email = '$colname_rsMail'");

 

Use

$query_email = mysql_query("SELECT email FROM dashboard_registration WHERE email = '$colname_rsMail'");

Link to comment
https://forums.phpfreaks.com/topic/124554-expert-help-please/#findComment-643354
Share on other sites

Thank you for all the responses. I tried them and it still doesnt work. Here is what I have now.

 

<?php
$colname_rsMail = "-1";
if (isset($_POST['email'])) {
   	$colname_rsMail = $_POST['email'];
mysql_select_db($database_connRegistration, $connRegistration);
$query_email = sprintf("SELECT email FROM dashboard_registration WHERE email = '%s'", $colname_rsMail);
$email = mysql_query($query_email, $connRegistration) or die(mysql_error());
$emailError = false;

if (mysql_num_rows($email) !== 0)
{
	$emailError = "That email address has already been registered.";
}
//Error exists, reformat values for repopulating fields
$email = stripslashes($email);
}

 

In the head & body

<head><?php echo $tNGs->displayValidationRules(); echo $emailError;?></head>
<body>
<input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email'];?>" size="32" />
<?php echo $emailError; echo $tNGs->displayFieldError("dashboard_registration", "email");?>
</body>

Link to comment
https://forums.phpfreaks.com/topic/124554-expert-help-please/#findComment-643737
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.