sonic656
01-06-2012, 08:16 PM
hi.....I need to have random 10nums in one string, without spaces or dots.
I tried this:
$delcode = rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9);
but on site that message appeared:
Notice: Undefined variable: delcode in /opt/lampp/htdocs/newsletter/index.php on line 16
here is all my code:
<?php
$title = "Newsletter";
include('../header.php');
include("../functions/mysql_con.php");
$delcode = rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9);
function sendmail($to) {
$subject = "[site] - Registrácia do newsletteru";
$message = '
Vážený zákazník,
ďakujeme Vám za registráciu do newsletteru na našej stránke.
Ak sa chcete odhlásiť z newsletteru, kliknite <a href="http://[site].sk/newsletter/odhlasenie/?id='.$delcode.'">sem</a>.';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: [site].sk <newsletter@[site].sk>' . "\r\n";
mail($to,$subject,$message,$headers);
}
if ($_POST['send']) {
$old = array("\"", "\'", "<", ">", "(", ")", ";", "ľ", "š", "č", "ť", "ž", "ý", "á", "í", "é", "ň", "ú", "ä", "ô");
$new = array(""", "'", "<", "(", ")", ";", ">", "Äľ", "š", "ÄŤ", "ĹĄ", "Ĺľ", "Ă˝", "á", "Ă*", "Ă©", "Ĺˆ", "Ăş", "ä", "Ă´");
$email = str_replace($new, $old, $_POST['email']);
if (strcmp($_POST['email'],"")) {
if (mysql_query("INSERT INTO newsletter (mail,del_code) VALUES ('".$email."','".$delcode."')") && sendmail($email))
{
echo '
<div id="content" align="center">
<h2>Úspešne ste sa registrovali do newsletteru</h2>
</div>
<meta http-equiv="refresh" content="2;url=/">
';
}
else {
echo '
<div id="content" align="center">
<h2>Vyskitol sa problém pri registrácii</h2>
<p>Prosím skuste neskôr.</p>
</div>
';
}
}
else {
echo '
<div id="content" align="center">
<h2>Nezadali ste svoj e-mail</h2>
<table>
<form action="/newsletter/index.php" method="post">
<tr><td>Váš e-mail: </td><td><input type="text" name="email" maxlength="350" /></td></tr>
<tr><td colspan="2"><input type="hidden" name="send" value="1" /></td></tr>
<tr><td colspan="2"><input type="submit" value="Prihlásiť sa do newsletteru" /></td></tr>
</form>
</table>
</div>
';
}
}
include("../functions/mysql_close.php");
include('../footer.php'); ?>
where is the problem?
Thanks in advance.
I tried this:
$delcode = rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9);
but on site that message appeared:
Notice: Undefined variable: delcode in /opt/lampp/htdocs/newsletter/index.php on line 16
here is all my code:
<?php
$title = "Newsletter";
include('../header.php');
include("../functions/mysql_con.php");
$delcode = rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9);
function sendmail($to) {
$subject = "[site] - Registrácia do newsletteru";
$message = '
Vážený zákazník,
ďakujeme Vám za registráciu do newsletteru na našej stránke.
Ak sa chcete odhlásiť z newsletteru, kliknite <a href="http://[site].sk/newsletter/odhlasenie/?id='.$delcode.'">sem</a>.';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: [site].sk <newsletter@[site].sk>' . "\r\n";
mail($to,$subject,$message,$headers);
}
if ($_POST['send']) {
$old = array("\"", "\'", "<", ">", "(", ")", ";", "ľ", "š", "č", "ť", "ž", "ý", "á", "í", "é", "ň", "ú", "ä", "ô");
$new = array(""", "'", "<", "(", ")", ";", ">", "Äľ", "š", "ÄŤ", "ĹĄ", "Ĺľ", "Ă˝", "á", "Ă*", "Ă©", "Ĺˆ", "Ăş", "ä", "Ă´");
$email = str_replace($new, $old, $_POST['email']);
if (strcmp($_POST['email'],"")) {
if (mysql_query("INSERT INTO newsletter (mail,del_code) VALUES ('".$email."','".$delcode."')") && sendmail($email))
{
echo '
<div id="content" align="center">
<h2>Úspešne ste sa registrovali do newsletteru</h2>
</div>
<meta http-equiv="refresh" content="2;url=/">
';
}
else {
echo '
<div id="content" align="center">
<h2>Vyskitol sa problém pri registrácii</h2>
<p>Prosím skuste neskôr.</p>
</div>
';
}
}
else {
echo '
<div id="content" align="center">
<h2>Nezadali ste svoj e-mail</h2>
<table>
<form action="/newsletter/index.php" method="post">
<tr><td>Váš e-mail: </td><td><input type="text" name="email" maxlength="350" /></td></tr>
<tr><td colspan="2"><input type="hidden" name="send" value="1" /></td></tr>
<tr><td colspan="2"><input type="submit" value="Prihlásiť sa do newsletteru" /></td></tr>
</form>
</table>
</div>
';
}
}
include("../functions/mysql_close.php");
include('../footer.php'); ?>
where is the problem?
Thanks in advance.