Plz fix ad4ean forget password code

Started on the old forum in July 2012 · view the original in the archive · old links redirect here

16 replies · 942 views · started 14 years ago · 1 min read

3 participants
Nepsalone Developer · 76 posts #1
<title>Nepali AD Network | Forgot Password</title>
<?php 
 include "inc/header.php";
 include "inc/def.php";
 include "inc/usrchk.php";
if($guest==0) {
    header("location:home.php");
}
?>

<?php
function rndgen ($minlength, $maxlength, $useupper, $usespecial, $usenumbers)
{
$charset = "abcdefghijklmnopqrstuvwxyz";
if ($useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if ($usenumbers) $charset .= "0123456789";
if ($usespecial) $charset .= "~@#$%^*()_+-={}|]["; // Note: using all special characters this reads: "~!@#$%^&*()_+`-={}|\\]?[\":;'><,./";
if ($minlength > $maxlength) $length = mt_rand ($maxlength, $minlength);
else $length = mt_rand ($minlength, $maxlength);
for ($i=0; $i<$length; $i++) $key .= $charset[(mt_rand(0,(strlen($charset)-1)))];
return $key;
}
$hammad = rand(1,1000);
$code = secure('code');
$sec = secure('secode');
if(isset($_POST['mail'])) {
$mail = secure('mail');
$get = mysql_query("SELECT * FROM users WHERE mail='$mail'") or die('Oops Error....');
$get1 = mysql_fetch_array($get);
$usr = $get1['user'];
$mail = $get1['mail'];
$id = $get1['id'];
if($sec!=$code)
{
    print "<div class='prob'>Wrong security code !</div>";
    die();
}
if(mysql_num_rows($get)==0) {
    die("NO such user !");
} else {
    $key = rndgen(10,10,false,false,true);
$pass = md5($key);    
}
$dox = mysql_query("UPDATE users SET pass='$pass' WHERE id='$id'");
$to = "$mail";
$subject = "Password Reset - NepalAD Network";
$message = "Hello $usr
You have Just Request New Password.
Your New passwod : $key
Regards
AdNepal Team";
$from = "noreply@nepalwap.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
if($dox) {
    print "<div class='adbox'>New Password Have Been Send to Your Email. Now  Login<a href='login.php'>here</a></div>";
}
?>
<div class="line">Forgot Password ?</div>
<form action="forgot.php" method="post">
<div class="lgn">E-Mail Address : <br />
<input size="30" maxlength="35" type="text" name="mail" /></div>
<?php
echo "<div class='lgn'>Security Code : '$hammad'<br />
<input size='30' maxlength='3' type='hidden' value ='$hammad' name='secode' />
<input size='30' maxlength='3' type='text' name='code' /></div>
<div class='lwt'>
<input type='submit' value='Get password' />
</div>";
?>
</form>
<a href="login.php"><b>Login here</b></a>
<?php include "inc/footer.php"; ?>

http://nepalwap.com 1st Nepali Mobile site...

Ghost Senior · 366 posts #2

please edit you post and wrap the code in a php bbcode.

posts like this just make the threads ugly and hard to read.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Ghost Senior · 366 posts #4

Nepsalone wrote: Ghost plz fix it

try this

<title>Nepali AD Network | Forgot Password</title> 
<?php  
 include("inc/header.php"); 
 include("inc/def.php"); 
 include("inc/usrchk.php"); 
if($guest==0) { 
    header("location:home.php"); 
} 
?> 

<?php 
function rndgen ($minlength, $maxlength, $useupper, $usespecial, $usenumbers) 
{ 
$charset = "abcdefghijklmnopqrstuvwxyz"; 
if ($useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
if ($usenumbers) $charset .= "0123456789"; 
if ($usespecial) $charset .= "~@#$%^*()_+-={}|]["; // Note: using all special characters this reads: "~!@#$%^&*()_+`-={}|\\]?[\":;'><,./"; 
if ($minlength > $maxlength) $length = mt_rand ($maxlength, $minlength); 
else $length = mt_rand ($minlength, $maxlength); 
for ($i=0; $i<$length; $i++) $key .= $charset[(mt_rand(0,(strlen($charset)-1)))]; 
return $key; 
} 
$hammad = rand(1,1000); 
$code = secure('code'); 
$sec = secure('secode'); 
if(isset($_POST['mail'])) { 
$mail = secure('mail'); 
$get = mysql_query("SELECT * FROM users WHERE mail='$mail'") or die('Oops Error....'); 
$get1 = mysql_fetch_array($get); 
$usr = $get1['user']; 
$mail = $get1['mail']; 
$id = $get1['id']; 
if($sec!=$code) 
{ 
    print "<div class='prob'>Wrong security code !</div>"; 
    die(); 
} 
if(mysql_num_rows($get)==0) { 
    die("NO such user !"); 
} else { 
    $key = rndgen(10,10,false,false,true); 
$pass = md5($key);     
} 
$dox = mysql_query("UPDATE users SET pass='$pass' WHERE id='$id'"); 
$to = "$mail"; 
$subject = "Password Reset - NepalAD Network"; 
$message = "Hello $usr 
You have Just Request New Password. 
Your New passwod : $key 
Regards 
AdNepal Team"; 
$from = "noreply@nepalwap.com"; 
$headers = "From: $from"; 
mail($to,$subject,$message,$headers); 
if($dox) { 
    print "<div class='adbox'>New Password Have Been Send to Your Email. Now  Login<a href='login.php'>here</a></div>"; 
}
} 
?> 
<div class="line">Forgot Password ?</div> 
<form action="forgot.php" method="post"> 
<div class="lgn">E-Mail Address : <br /> 
<input size="30" maxlength="35" type="text" name="mail" /></div> 
<?php
echo "<div class='lgn'>Security Code : '$hammad'<br /> 
<input size='30' maxlength='3' type='hidden' value ='$hammad' name='secode' /> 
<input size='30' maxlength='3' type='text' name='code' /></div> 
<div class='lwt'> 
<input type='submit' value='Get password' /> 
</div>"; 
?> 
</form> 
<a href="login.php"><b>Login here</b></a> 
<?php include("inc/footer.php"); ?>

sytax error free. it was missing a } in the code and also ( ) on includes

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Ghost Senior · 366 posts #7

Nepsalone wrote: requesting my forget password option my site redirecting to 404 page not found page. Please check it Nepali Mobile AD Network

im facing once more problem in my host guest also can acces my user control panel page check it User Cpanel

try changing >>> <form action="forgot.php" method="post"> to this >>> <form action="forgotpass.php" method="post">

as your file is calling itself it needs to be the same name as the file you named it.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Nepsalone Developer · 76 posts #8

my 1st problem solved. what can i do for second option plz help me im working in this script at last 15 days bt i cant solve this problem. This script working fine in wamp server

http://nepalwap.com 1st Nepali Mobile site...

Ghost Senior · 366 posts #9

for your cpanel error we would have to see the file in question. although that doesnt mean ill be able to fix it. but it does mean other ppl have a chance to help you also as they too can see the code.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Nepsalone Developer · 76 posts #10

im also getting this problem in http://nepalwap.com.nu bro wait im upload here my eror log file

Added after 2 minutes:

[16-Jul-2012 13:16:55] PHP Warning: Cannot modify header information - headers already sent by (output started at /home3/nepalwap/public_html/ads/home.php:5) in /home3/nepalwap/public_html/ads/home.php on line 8 [16-Jul-2012 13:20:21] PHP Warning: Cannot modify header information - headers already sent by (output started at /home3/nepalwap/public_html/ads/home.php:5) in /home3/nepalwap/public_html/ads/home.php on line 8 [16-Jul-2012 13:34:08] PHP Warning: Cannot modify header information - headers already sent by (output started at /home3/nepalwap/public_html/ads/home.php:5) in /home3/nepalwap/public_html/ads/home.php on line 8

http://nepalwap.com 1st Nepali Mobile site...

Ghost Senior · 366 posts #11

you could try putting something like this at top of page but not sure how it will work out 100% for you.

  /** Prevent direct access from url to this file */
if (stristr(htmlentities($_SERVER['SCRIPT_NAME']), 'home.php')) 
{
echo '<meta http-equiv="Refresh" content="0; url=../../index.php">';
     die();
}
//
//
//
//

or try make it more secure so only you can access it.

  /** Prevent direct access from url to this file */
if (stristr(htmlentities($_SERVER['SCRIPT_NAME']), 'home.php')) 
{
echo '<meta http-equiv="Refresh" content="0; url=../../index.php">';
     die();
}
else if($password == 'password' && $username == 'username')
{
//show script inside here.
}
//
//
//
//

the if($password == 'password' && $username == 'username') section would need modding to your database details

i dont normally go near mysql files so this is just a php throw together.

just a suggestion. but im pretty sure other ppl will chime in here with much better solutions to suit your needs more.

Added after 3 minutes:

Nepsalone wrote: im also getting this problem in Nepali Mobile AD Network bro wait im upload here my eror log file

Added after 2 minutes:

[16-Jul-2012 13:16:55] PHP Warning: Cannot modify header information - headers already sent by (output started at /home3/nepalwap/public_html/ads/home.php:5) in /home3/nepalwap/public_html/ads/home.php on line 8 [16-Jul-2012 13:20:21] PHP Warning: Cannot modify header information - headers already sent by (output started at /home3/nepalwap/public_html/ads/home.php:5) in /home3/nepalwap/public_html/ads/home.php on line 8 [16-Jul-2012 13:34:08] PHP Warning: Cannot modify header information - headers already sent by (output started at /home3/nepalwap/public_html/ads/home.php:5) in /home3/nepalwap/public_html/ads/home.php on line 8

this is a commen problem with headers. when another header is also being sent from an include file.

try changing this

    header("location:home.php");  
 

//
//
//

to this

 echo '<meta http-equiv="Refresh" content="0; url=home.php">';

//
//

it should fix it.

obviously change the home.php to the correct file your header is pointing to. i took this header details from the posts above (forgotpass.php) as an example

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Nepsalone Developer · 76 posts #12

ok bro im try to fix it bro im pasting here my home.php code

<html>
<title> User Cpanel</title>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<link href="style.css" rel="stylesheet" type="text/css" />
<?php include "inc/def.php"; ?>
<?php include "inc/usrchk.php";
if($guest==1) {
    header("location:index.php");
} ?>

<div class="blk">
<b>Hello, <?php echo $user; ?></b>
</div>
<?php if($guest==0) { ?>
<?php
$getu = mysql_query("SELECT * FROM users WHERE user='$user'");
$getu1 = mysql_fetch_array($getu);
$id = $getu1['id'];
$bal = $getu1['bal'];
$pnt = $getu1['point'];
$getimp = mysql_query("SELECT * FROM imp WHERE uid='$id'");
$imp = mysql_num_rows($getimp);
$getclk = mysql_query("SELECT * FROM clicks WHERE uid='$id'");
$clk = mysql_num_rows($getclk);
print "<div class='lwt'>You Have <font color=red>$pnt</font>Publisher Points</div>";
?>
<?php } else { ?>
<?php } ?>
<div class="line">Account Panel</div>
<div class="lwt"><a href="changepass.php">Change Password</a></div>
<div class="lgn"><a href="editac.php">Edit Account Details</a></div>

<div class="line">Publisher Panel</div>
<div class="lgn"><a href="pub_htmlcode.php">Get HTML Code</a></div>
<div class="lwt"><a href="pub_phpcode.php">Get PHP Code</a></div>
<div class="lgn"><a href="pub_history.php">Earning Statistics & Payout</a></div>
<div class="lwt"><a href="pub_today.php">Today's Statistics</a></div>

<div class="line">Advertiser Panel</div>
<div class="lwt"><a href="adv_create.php">Create Ur Advertise</a></div>
<div class="lgn"><a href="adv_history.php">History</a>
</div>
<div class="lwt"><a href="adv_view.php">View Campaigns</a></div>
<div class="line"><a href="logout.php">Logout</a></div>
<?php include "inc/footer.php"; ?>
</html>

http://nepalwap.com 1st Nepali Mobile site...

Ghost Senior · 366 posts #13
<html> 
<title> User Cpanel</title> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">  
<link href="style.css" rel="stylesheet" type="text/css" /> 
<?php include("inc/def.php"); ?> 
<?php include("inc/usrchk.php"); 
if($guest==1) { 
echo '<meta http-equiv="Refresh" content="0; url=index.php">';
} ?> 

<div class="blk"> 
<b>Hello, <?php echo $user; ?></b> 
</div> 
<?php if($guest==0) { ?> 
<?php 
$getu = mysql_query("SELECT * FROM users WHERE user='$user'"); 
$getu1 = mysql_fetch_array($getu); 
$id = $getu1['id']; 
$bal = $getu1['bal']; 
$pnt = $getu1['point']; 
$getimp = mysql_query("SELECT * FROM imp WHERE uid='$id'"); 
$imp = mysql_num_rows($getimp); 
$getclk = mysql_query("SELECT * FROM clicks WHERE uid='$id'"); 
$clk = mysql_num_rows($getclk); 
print "<div class='lwt'>You Have <font color=red>$pnt</font>Publisher Points</div>"; 
?> 
<?php } else { ?> 
<?php } ?> 
<div class="line">Account Panel</div> 
<div class="lwt"><a href="changepass.php">Change Password</a></div> 
<div class="lgn"><a href="editac.php">Edit Account Details</a></div> 

<div class="line">Publisher Panel</div> 
<div class="lgn"><a href="pub_htmlcode.php">Get HTML Code</a></div> 
<div class="lwt"><a href="pub_phpcode.php">Get PHP Code</a></div> 
<div class="lgn"><a href="pub_history.php">Earning Statistics & Payout</a></div> 
<div class="lwt"><a href="pub_today.php">Today's Statistics</a></div> 

<div class="line">Advertiser Panel</div> 
<div class="lwt"><a href="adv_create.php">Create Ur Advertise</a></div> 
<div class="lgn"><a href="adv_history.php">History</a> 
</div> 
<div class="lwt"><a href="adv_view.php">View Campaigns</a></div> 
<div class="line"><a href="logout.php">Logout</a></div> 
<?php include("inc/footer.php"); ?> 
</html>

try that to start with.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Nepsalone Developer · 76 posts #14

after putting ds code im unable to login my site

Added after 4 minutes:

thanx bro its working fine

Added after 2 minutes:

Now my all problem solved thanx my dear Ghost im so happy with U. I hope U help me next time also.

http://nepalwap.com 1st Nepali Mobile site...

Ghost Senior · 366 posts #15

Edit oh good its fixed then? your welcome. glad i was able to help somehow 🙂

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
Nepsalone Developer · 76 posts #16

guest==1, mean all guest can acces this page guest==0,only user can acces this page

http://nepalwap.com 1st Nepali Mobile site...

Ghost Senior · 366 posts #17

cool then yeah that makes sence now lol. i should of actually asked that at the start maybe. still glad your sorted now 🙂

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close