Hy,
Hab ein Problem,
Wenn ein User sich registriert hat , soll er eine Email mit einem link bekommen.
Format host.de/active.php?id=X&code=XXXX
Die Email wird aber nicht versendet nach der Registrierung....
Und noch ne frage, gibts nen öffnetlichen mailserver oder kann das auch lammp ? Habe ubuntu...
Hab ein Problem,
Wenn ein User sich registriert hat , soll er eine Email mit einem link bekommen.
Format host.de/active.php?id=X&code=XXXX
Die Email wird aber nicht versendet nach der Registrierung....
PHP:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$random = rand(23456789,98765432);
if (isset($_POST['submit'])) {
$userDatas = array(
'username' => isset($_POST['username']) ? (string)trim($_POST['username']) : '',
'email' => isset($_POST['email']) ? (string)trim($_POST['email']) : '',
'password' => isset($_POST['password']) ? (string)trim($_POST['password']) : '',
'repeat_password' => isset($_POST['repeatpassword']) ? (string)trim($_POST['repeatpassword']) : '',
'random' => rand(23456789,98765432),
'date' => date('Y-m-d'));
// an empty input is not allowed
if (!empty($userDatas['username']) && !empty($userDatas['email']) &&
!empty($userDatas['password']) && !empty($userDatas['repeat_password'])) {
if ($userDatas['password'] == $userDatas['repeat_password']) {
include ('../config/mysql_connect.php');
$sql = "INSERT INTO `users`
(
`id`,
`username`,
`password`,
`date`,
`email`,
`random`,
`activated`
)
VALUES
(
'',
'".mysql_real_escape_string($userDatas['username'])."',
'".mysql_real_escape_string(md5($userDatas['password']))."',
'".mysql_real_escape_string($userDatas['date'])."',
'".mysql_real_escape_string($userDatas['email'])."',
'".mysql_real_escape_string($userDatas['random'])."',
'0'
)";
$lastid = mysql_insert_id();
//send email to acticated
$to = $email;
$subject = "Aktivierung deinen Accounts";
$headers = "From: [email protected]";
$server = "mailhost.sheddield.ac.uk";
$body = "Hallo $username ,\n\n
Bitte aktiviere deinen Account indem du auf dein unten angeführten Link klickst.
http://localhost/hosting/login/active.php?id=$lastid&code=$random \n\n
Thanks!
";
//function to send email
mail($to, $subject, $body, $headers) ;
$result = mysql_query($sql);
if ($result) {
die('Registrierung erfolgreich. <a href="index.php">Login</a>');
}
} else {
echo 'Passwörter stimmen nicht überein';
}
} else {
echo 'Bitte füllen sie die gekennzeichneten felder aus.';
}
}
?>
<form action='register.php' method='POST'>
<table>
<tr>
<td>
Username
</td>
<td>
<input type='text' name='username' value='<?php echo isset($_POST['username']) ? htmlentities(trim($_POST['username'])) : ''; ?>' />
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<input type='text' name='email' value='<?php echo isset($_POST['email']) ? htmlentities(trim($_POST['email'])) : ''; ?>' />
</td>
</tr>
<tr>
<td>
Passwort:
</td>
<td>
<input type='password' name='password' />
</td>
</tr>
<tr>
<td>
Passwort Wiederholung:
</td>
<td>
<input type='password' name='repeatpassword' />
</td>
</tr>
</table>
<p>
<input type='submit' name='submit' value='Register' />
Und noch ne frage, gibts nen öffnetlichen mailserver oder kann das auch lammp ? Habe ubuntu...