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
https://forums.phpfreaks.com/topic/123683-expert-needed/
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
https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638697
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
https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638704
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
https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638709
Share on other sites

  • 4 weeks later...

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.