Jump to content

EXPERT NEEDED!!


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)

 

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

<?php 
if (isset($_POST['email'])) {
    $email = trim($_POST['email']);
    $emailError = false;
    $query = "SELECT * FROM users WHERE email = '$email'";
    $result = mysql_query($query) or die (mysql_error());
    if (mysql_num_rows($result)!== 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??

<head>
<?php echo $tNGs->displayValidationRules();?>
</head>
<body>
    <form name="testForm" method="POST">
     <input name="email" type="text" id="email" 
         value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" />
<?php echo $tNGs->displayFieldError("dashboard_registration", "email"); ?>
    <button type="submit">Submit Data</button>
    </form>
</body>

Link to comment
Share on other sites

Like this? I wasnt sure if you could put two echo's or two snippets of code in one braquet?

 

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

 

Link to comment
Share on other sites

This is what I tried and it sent me to a blank page with this error: "No database selected"

 

PRECODE

<?php 
if (isset($_POST['email'])) {
    $email = trim($_POST['email']);
    $emailError = false;

    $query = "SELECT * FROM users WHERE email = '$email'";
    $result = mysql_query($query) or die (mysql_error());
    if (mysql_num_rows($result)!== 0)
    {
        $emailError = "That email address has already been registered.";
    }

    //Error exists, reformat values for repopulating fields
    $email = stripslashes($email);

$colname_rsMail = $_POST['email'];
}?>

 

 

MY CODE IN MY BODY

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

Link to comment
Share on other sites

Hahhaah really? I had no idea. Here is what I tried. Still doesnt work.

 

<?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'");
//$query = "SELECT email FROM dashboard_registration WHERE email = '$email'";
$email = mysql_query($query_email, $connRegistration) or die(mysql_error());
//$email = trim($_POST['email']);
$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);
}?>

Link to comment
Share on other sites

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.