473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

email part doesn't work

134 100+
I've created a login script for my website. But my registration file gives an error when it reaches the point at which it should send an auto activation script. The error it gives is "failed to send activation mail" the error is on line 43. If anyone knows a solution, please tell me.

Thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. include("config.php");
  2. include("htmltop.php");
  3.  
  4. if(!isset($_SESSION['user_id'])) {
  5.  if(isset($_POST['submit'])) {
  6.   // Uitvoeren
  7.   // Velden controleren
  8.   if($_POST['user'] != "" AND $_POST['pass1'] != "" AND $_POST['pass2'] != "" AND $_POST['email'] != "") {
  9.    // Gebuikersnaamcheck
  10.    $sql = "SELECT id FROM gebruikers WHERE naam='".$_POST['user']."'";
  11.    $query = mysql_query($sql);
  12.    $tellen = mysql_num_rows($query);
  13.    if($tellen == 0) {
  14.     // E-mailcheck
  15.     if(preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/i", $_POST['email'])) {
  16.      // Email correct
  17.      if($_POST['pass1'] == $_POST['pass2']) {
  18.       $actcode = mt_srand((double)microtime()*100000);
  19.       while(strlen($actcode) <= 10) {
  20.        $i = chr(mt_rand (0,255));
  21.        if(eregi("^[a-z0-9]$", $i)) {
  22.         $actcode = $actcode.$i;
  23.        }
  24.       }
  25.       $md5pass = md5($_POST['pass1']);
  26.       $sql = "INSERT INTO gebruikers (naam,wachtwoord,status,email,actief,actcode) VALUES ('".$_POST['user']."','".$md5pass."',0,'".$_POST['email']."',0,'".$actcode."')";
  27.       $query = mysql_query($sql);
  28.       if($query == TRUE) {
  29.        $sql = "SELECT id FROM gebruikers WHERE naam='".$_POST['user']."'";
  30.        $query = mysql_query($sql);
  31.        $rij = mysql_fetch_object($query);
  32.        $dbid = htmlspecialchars($rij->id);
  33.        $bericht = "Beste ".$_POST['user'].",\nJe hebt je geregistreerd op de site ".$sitenaam.", dit is de activatie mail van je registratie.\nOm je account te activeren, druk je op de link onderaan deze mail.\n\n";
  34.        $bericht .= "REGISTRATIE BEVESTIGEN: ".$forgoturl."activeren.php?id=".$dbid."&code=".$actcode."&registratie=true \n\n";
  35.        $bericht .= "Zodra je op deze link geklikt hebt, kun je inloggen met:\n";
  36.        $bericht .= "Gebruikersnaam: ".$_POST['user']."\n";
  37.        $bericht .= "Wachtwoord: ".$_POST['pass1']."\n";
  38.        $bericht .= "** Dit is een automatisch verzonden bericht **";
  39.        $mail = mail($_POST['email'],"Registratie ".$sitenaam,$bericht,"From: ".$sitenaam." <".$sitemail.">");
  40.        if($mail == TRUE) {
  41.         echo "Je bent succesvol geregistreerd! Zodra je de link in de mail hebt bezocht kun je inloggen.<br />\n<a href=\"inloggen.php\">&laquo; Naar de inlogpagina</a>";
  42.        }else{
  43.         echo "Fout opgetreden tijdens verzenden van e-mail. Neem contact op met <a href=\"mailto:".$sitemail."\">".$sitemail."</a>.";
  44.        }
  45.       }else{
  46.        echo "Er is een fout opgetreden tijdens het toevoegen van je account. Probeer het later nog eens.<br />\n<a href=\"javascript:history.back()\">&laquo; Ga terug</a>";
  47.       }
  48.      }else{
  49.       echo "De door jou opgegeven wachtwoorden komen niet overeen.<br />\n<a href=\"javascript:history.back()\">&laquo; Ga terug</a>";
  50.      }
  51.     }else{
  52.      echo "Het e-mailadres dat jij opgaf, komt niet overeen met hoe een e-mailadres eruit zou moeten zien (gebruiker@domain.ext).<br />\n<a href=\"javascript:history.back()\">&laquo; Ga terug</a>";
  53.     }
  54.    }else{
  55.     echo "De gebruikersnaam '".$_POST['user']."' is reeds in gebruik. Probeer een andere gebruikersnaam.<br />\n<a href=\"javascript:history.back()\">&laquo; Ga terug</a>";
  56.    }
  57.   }else{
  58.    echo "Je bent vergeten één of meerdere velden in te vullen.<br />\n<a href=\"javascript:history.back()\">&laquo; Ga terug</a>";
  59.   }
  60.  }else{
  61.   // Formulier
  62.  
  63.   # Email
  64.   # User
  65.   # Pass + check
  66.   # emailcheck (uitvoeren)
  67.   ?>
  68.   <form method="post" action="registreer.php">
  69.    <table>
  70.     <tr>
  71.      <td>Gebruikersnaam:</td><td><input type="text" name="user" maxlength="50" /></td>
  72.     </tr>
  73.     <tr>
  74.      <td>Wachtwoord:</td><td><input type="password" name="pass1" /></td>
  75.     </tr>
  76.     <tr>
  77.      <td>Herhaal:</td><td><input type="password" name="pass2" /></td>
  78.     </tr>
  79.     <tr>
  80.      <td>E-mailadres:</td><td><input type="text" name="email" maxlength="100" /></td>
  81.     </tr>
  82.     <tr>
  83.      <td></td><td><input type="submit" name="submit" value="Registreer" /></td>
  84.     </tr>
  85.    </table>
  86.   </form>
  87.   <small>Na de registratie zal er een e-mail naar je e-mailadres gestuurd worden ter activatie. Tot die tijd kun
  88.   je nog niet inloggen.</small>
  89.   <?
  90.  }
  91. }else{
  92.  echo "Je bent momenteel ingelogd, registreren is niet mogelijk terwijl je bent ingelogd!";
  93. }
  94.  
Jun 16 '11 #1
0 1143

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: red | last post by:
within an object function, this code: $test2='test'; echo "$test"; $this->test2='test2'; echo "$this->test2\n"; produces this result: test2
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
5
by: Paxton | last post by:
I created an html email containing a form whose method is POST. The form is posted to an asp page for processing, but no values are retrieved. So I response.write all the Request.Form fields, and...
4
by: Iver Erling Årva | last post by:
I have an application that uses a window.open() to open it's own main window where all my programs takes place. I use a timeout so if nothing goes on for 15 minutes the document below is called. To...
6
by: Cliff R. | last post by:
Hi, I use a handy little Javascript Flash detection script on a number of sites (copied below). Usually works great, but I just started trying Firefox and it's not working. A few browsers are...
11
by: Brett | last post by:
I have an assembly on a shared LAN drive. On my developer machine, I give that assembly full trust from the .NET wizard. It works fine. I go to a user machine on the LAN, map to the shared...
5
by: fab | last post by:
Hello, i'm trying to browse a UNC share through an ASP.NET application and i've got a problem : i've tried some examples from MSDN or other web sites (using LogonUser from Win32 API) and it...
1
by: Karl | last post by:
I have a simple tool bar used for reports. It shows at the top of previewed reports and allows the user to print the report or close the view. The close part of the tool bar doesn't work in A2007....
3
by: Vincent | last post by:
Hi, With this CreateuserWizard code, i have two problems: 1) when email is left empty ="email not valid." and not "E-mailadres is required." (never shown). When is "E-mailadres is required."...
3
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
Note: My apologies for repeating this post from last week, but my nospam alias and profile account were incorrect. I think I have fixed this, so hopefully this post will trigger MS into a response...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.