Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:44:49+00:00 2026-06-13T14:44:49+00:00

I am trying to create an email validation form for my database but am

  • 0

I am trying to create an email validation form for my database but am having a number of issues. When i try and run the code below i get the error no database selected.

I also get an undefined variable error. I want the put the name of the user into my database under the username field, but apparently $name is an undefined variable. error on line xx undefined variablemysql_query("INSERT INTO registrations (username, password, email, hash) VALUES( '". mysql_real_escape_string($name) ."',.

I am using WAMP server. The name of the database is sitememberdetails, and the name of the
table i need the information put into is registrations. I am pretty new to this – Could anyone tell me how i would define the variable and how i select the db( even though it already appears to be selected?)

     <?php

             $host = "localhost";
             $username = "";
             $password = "";
             $databasename = "sitememberdetails";
             $email="xxxxxx@xxxxxxxx.xxx";


              $connection = mysql_connect($host,$username,$password) or die        
             ("Error: ".mysql_error());

               mysql_select_db($databasename);("sitememberdetails") or  

               die(mysql_error());   



                    if(isset($_POST['name']) && !empty($_POST['name']) AND  

                    isset($_POST['email']) && !empty($_POST['email'])){  
                     $name = mysql_real_escape_string($_POST['name']);  
                     $email = mysql_real_escape_string($_POST['email']); }  



                      if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a- 

                        z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){

$msg = 'The email you have entered is invalid, please try again.';  
                }else{  

                    $msg = 'Your account has been made, <br /> please verify it     

              by clicking the activation link that has been send to  

                 your email.';  
                       }  


                        $hash = md5( rand(0,1000) ); 


                         $password = rand(1000,5000); 



                        mysql_query("INSERT INTO registrations (username, password,  

                          email, hash) VALUES( 
                          '". mysql_real_escape_string($name) ."', 
                          '". mysql_real_escape_string(md5($password)) ."', 
                          '". mysql_real_escape_string($email) ."', 
                          '". mysql_real_escape_string($hash) ."') ") or  

                          die(mysql_error());



                             $to      = $email; // Send email to our user  
                      $subject = 'Signup | Verification'; // Give the email a subject  
                      $message = ' 
                       Thanks for signing up! 
                      Your account has been created, you can login with the following  

                       credentials after you have activated your account by pressing  

                       the url below. 

                 Username: '.$name.' 
                 Password: '.$password.' 

                      Please click this link to activate your account: 
                      http://www.yourwebsite.com/verify.php?email='.$email.'& 

                      hash='.$hash.' 
                       ';  
                     $headers = 'From:noreply@yourwebsite.com' . "\r\n"; // Set from  

                       headers  
                       mail($to, $subject, $message, $headers); // Send our email  


                        ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:44:52+00:00Added an answer on June 13, 2026 at 2:44 pm

    try changing this code

    mysql_select_db($databasename);("sitememberdetails") or  
    
               die(mysql_error());
    

    to this

    mysql_select_db($databasename) or  die(mysql_error());
    

    EOL;

    if (database_connection) {
    unset($undefined_variable_error)
    } else {
    echo $undefined_variable_error;
    }
    // Because mysql_real_escape_string needs an open mysql connection
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a new Dedicated Cache Role in Windows Azure but get the
I am trying to implement form validation using cakephp models. Here are my code
I'm trying to create a very simple email signup form, where the user can
Trying to create a python package. Seems to work, but i get a warning.
Hi I'm trying to create a simple registration form with ajax validation. I've got
Basically I am trying to write some code to use for form validation, Im
I am trying to create a contact form using the remote_form_tag, but I cannot
I am trying to create a contact form that collects a name, email, message
I'm currently trying to create an email application using Rails and Sendgrid. This application
I am trying to create & save images from data in an email from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.