Below is my forget password, why cannot function?? When i click on the submit button, it still remain on the same page and just like i didn't click anything...
[PHP]<?php
if($go == "1")
{
mysql_connect("localhost","root","");
mysql_select_db("ums e-job portal");
$sql = @mysql_query("SELECT * FROM company WHERE username='$username' && emailAdd='$email' ");
if(!$sql)
{
echo "The username and email address do not match.";
exit;
}
$query = mysql_query($sql);
$fPass = mysql_fetch_array($query);
$to = "SELECT * FROM company WHERE emailAdd='$email' ";
$subject = "Your Password";
$body = "SELECT * FROM company WHERE username='$username' && password='$password' ";
$headers = "From: admin@localhost.com\n";
mail($to, $subject, $body, $headers);
echo "Your Password has been sent to $to";
}
?>[/PHP]
[HTML]<form action="<?= $PHP_SELF ?>" method="post">
Username: <input type="text" name="username" size="24" border="0"><br>
E-mail: <input type="text" name="email" size="24" border="0"><br>
<input type="hidden" name="go" value="1" border="0"><input type="submit" name="submitButtonName" border="0">
</form[/HTML]>
52 5061
Are these both the same page?
Are these both the same page?
Ya... :)
I have seperate it after this, but it still cannot function, just link to the page got the php code but is blank...
Thanks...
Firstly, PHP_SELF should be changed to $_SERVER['PHP_SELF'] and perhaps you could try adding echo statements into your PHP to debug. For example, one just after your if statement, to see if you even reach the condition.
Atli 5,058
Expert 4TB
Hi.
MySQL databases can not have spaces.
So if this is really the database you try to connect to it will give you an error.
[PHP]mysql_select_db("ums e-job portal");[/PHP]
Try this to see if it is the error
[PHP]mysql_select_db("ums e-job portal") or die(mysql_error);[/PHP]
Atli 5,058
Expert 4TB
Also just noticed this.
[PHP]<form action="<?= $PHP_SELF ?>"[/PHP]
Dont know if the <?= is usable in older versions but it wont work in php 5.2
It should be <?php Note. that in PHP 5.2.0 <? is also wrong uless you have the 'short_open_tag' set to 'on' in your php.ini (default is off)
And as Steven said it is probbly better to write
$_SERVER['PHP_SELF'] rather than $PHP_SELF,
tho both will work on PHP 5
An you will have to acctually print it so you need to do echo or print
[PHP]<form action="<?php echo $_SERVER['PHP_SELF']; ?>"[/PHP]
THANKS Alti and Steven...
I modify the code ledy but still can't work...
And i try 2 detect the error by put
[PHP]<? error_reporting(E_ALL);[/PHP] as Alti told me before, the error message appear as below:
Notice: Undefined variable: go in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 3
which line 3 is [PHP]<? if($go == "1") ?>[/PHP]
And i have put the code:
[HTML]<input type="hidden" name="go" value="1" border="0"><input type="submit" name="submit" value="Submit" border="0">
</form>[/HTML]
at the bottom of the page...
Is it need to code something as below to define it??
[PHP]<?
$go=..........;
?>[/PHP]
BUt i don't know how to code it, can somebody give me some guildeline??? Thanks..
Atli 5,058
Expert 4TB
Try replacing it with
[PHP]$_REQUEST['go'][/PHP]
Also, its always best to close all HTML tags, like so.
[HTML]<input ...></input>
or
<input ... />[/HTML]
Try replacing it with
[PHP]$_REQUEST['go'][/PHP]
Also, its always best to close all HTML tags, like so.
[HTML]<input ...></input>
or
<input ... />[/HTML]
Thanks... I try already, but the error still same as below:
Notice: Undefined variable: go in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 3
What should i do??? I have no idea how to define the variable... Thanks..
Thanks... I try already, but the error still same as below:
Notice: Undefined variable: go in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 3
What should i do??? I have no idea how to define the variable... Thanks..
Post the latest version of your code.
Post the latest version of your code.
Thanks.. Below is my latest code... All the code is in same page...
[PHP]<?php
error_reporting(E_ALL);
if($_REQUEST['go'] == "1")
{
mysql_connect("localhost","root","");
mysql_select_db("ums e-job portal") or die(mysql_error);
$sql = @mysql_query("SELECT * FROM company WHERE username='$username' && emailAdd='$email'");
if(!$sql)
{
echo "The username and email address do not match.";
exit;
}
if(!empty($username)&&!empty($email)){
$query = mysql_query($sql)
or die("Cannot execute query");
}
$fPass = mysql_fetch_array($query);
$to = "SELECT * FROM company WHERE emailAdd='$email' ";
$subject = "Your Password";
$body = "SELECT * FROM company WHERE username='$username' && password='$password' ";
$headers = "From: admin@localhost.com\n";
mail($to, $subject, $body, $headers);
echo "Your Password has been sent to $to";
}
?>[/PHP]
[HTML]
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Username: <input type="text" name="username" size="24" border="0"><br>
E-mail: <input type="text" name="email" size="24" border="0"><br>
<input type="hidden" name="go" value="1" border="0"><input type="submit" name="submit" value="Submit" border="0">
</form>[/HTML]
Try changing
[PHP]<?php
error_reporting(E_ALL);
if($_REQUEST['go'] == "1") [/PHP]
to
[PHP]
<?php
error_reporting(E_ALL);
if($_POST['go'] == "1") [/PHP]
Atli 5,058
Expert 4TB
I tried your code, put it all in one .php file, and once I submitted the form, the unidentified index error dissapears.
I see no reason why this code should give you the error after you submit the form.
I did however notice this.
[PHP]// First query, ok
$sql = @mysql_query("SELECT * FROM company WHERE username='$username' && emailAdd='$email'");
if(!$sql)
{
echo "The username and email address do not match.";
exit;
}
// Second query, not ok
if(!empty($username)&&!empty($email)){
$query = mysql_query($sql) // <-- running the first query
or die("Cannot execute query");
}
$fPass = mysql_fetch_array($query); // <-- Fetching the second, incorrect query
[/PHP]
You are trying to run the same query twice, and the second time you'r running the ID number of the first one.
You should remove the second one and edit the mysql_fetch_array to use the first one.
Try changing
[PHP]<?php
error_reporting(E_ALL);
if($_REQUEST['go'] == "1") [/PHP]
to
[PHP]
<?php
error_reporting(E_ALL);
if($_POST['go'] == "1") [/PHP]
Emm.. I use as what you said, but din't work...
The error shown as below:
Notice: Undefined index: go in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 4
Thanks... :)
I tried your code, put it all in one .php file, and once I submitted the form, the unidentified index error dissapears.
I see no reason why this code should give you the error after you submit the form.
I did however notice this.
[PHP]// First query, ok
$sql = @mysql_query("SELECT * FROM company WHERE username='$username' && emailAdd='$email'");
if(!$sql)
{
echo "The username and email address do not match.";
exit;
}
// Second query, not ok
if(!empty($username)&&!empty($email)){
$query = mysql_query($sql) // <-- running the first query
or die("Cannot execute query");
}
$fPass = mysql_fetch_array($query); // <-- Fetching the second, incorrect query
[/PHP]
You are trying to run the same query twice, and the second time you'r running the ID number of the first one.
You should remove the second one and edit the mysql_fetch_array to use the first one.
Thanks, Alti..I delete the second query and the
[PHP]$fPass = mysql_fetch_array($query);[/PHP]
to
[PHP]$fPass = mysql_fetch_array($sql);[/PHP]
but it still go error, same error as below:
Notice: Undefined index: go in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 4
And after submit the username and email, the error as below...
Notice: Undefined variable: email in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 21
Notice: Undefined variable: username in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 23
Notice: Undefined variable: password in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 23
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 26
Your Password has been sent to SELECT * FROM company WHERE emailAdd=''
And i think it cannot defined the variable go, but i don't how 2 define it...
could someone give me a guildeline what is the problem of my forget password code??
Thanks... :)
could someone give me a guildeline what is the problem of my forget password code??
Thanks... :)
Except for the warning you don't have a problem in your code. All you get are notices and that is because you have set the
.
That error level setting is used only for debugging purposes and should be set off during production!
To get rid of these notices just comment that line out and only the real errors are left.
Ronald :cool:
Except for the warning you don't have a problem in your code. All you get are notices and that is because you have set the
.
That error level setting is used only for debugging purposes and should be set off during production!
To get rid of these notices just comment that line out and only the real errors are left.
Ronald :cool:
I have set off the
and test it, the output is:
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 25
Your Password has been sent to SELECT * FROM company WHERE emailAdd=''
Then i change the code after 25,
where the original is
[PHP]
$to = "SELECT * FROM company WHERE emailAdd='$email' ";
$subject = "Your Password";
$body = "SELECT * FROM company WHERE username='$username' && password='$password' ";
$headers = "From: admin@localhost.com\n";
[/PHP]
to
[PHP]$sql1 = @mysql_query("SELECT * FROM company WHERE emailAdd='$email' ");
$to = mysql_fetch_array($sql1);
$subject = "Your Password";
$sql2 = @mysql_query("SELECT * FROM company WHERE username='$username' && password='$password' ");
$body = mysql_fetch_array($sql2);
$headers = "From: localhost/admin.php\n";
[/PHP]
The ouput is same like original...
Emm...How to repair it?? Thanks..
(a) for the mail command you must either have specified the "FROM in php.ini mor set in in the header of your email. It must be an email address!!!
(b) you cannot, just like that, include the result of the query in your mail body because it is an array.
Anyway, why do you do the select when you already know the result, i.e. in variables $email, $username and $password????
If that is so, the mail setup can be like (example):
[php]
$to = $email;
$subject = "Your Password";
$body = "Username: $username\nPassword: $password\n";
$headers = "From: me@myhost.com";
if (mail($to, $subject, $body, $headers))
echo
echo "Mail successfully sent!";
else
echo "Error sending email";
[/php]
Ronald :cool:
(a) for the mail command you must either have specified the "FROM in php.ini mor set in in the header of your email. It must be an email address!!!
(b) you cannot, just like that, include the result of the query in your mail body because it is an array.
Anyway, why do you do the select when you already know the result, i.e. in variables $email, $username and $password????
If that is so, the mail setup can be like (example):
[php]
$to = $email;
$subject = "Your Password";
$body = "Username: $username\nPassword: $password\n";
$headers = "From: me@myhost.com";
if (mail($to, $subject, $body, $headers))
echo
echo "Mail successfully sent!";
else
echo "Error sending email";
[/php]
Ronald :cool:
Emm.. is it edit hte code as what i edit below?? I edit my code, but the output still remain the same as below:
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 25
Error sending email
Below is my php code:
[PHP]$to = $email;
$subject = "Your Password";
$body = "Username: $username\nPassword: $password\n";
$headers = "From: bbheong0219@yahoo.com";
if(mail($to, $subject, $body, $headers)){
echo "Your Password has been sent to $to";
}
else{
echo "Error sending email";} [/PHP]
Thanks...
You have a problem with the 'sendmail_from' option in your php.ini file. If you cannot change your php.ini file, try it from the outside by inserting this statement just before you issue the mail(...) command
[php]ini_set(sendmail_from, "bbheong0219@yahoo.com"); // the INI lines are to force the From Address to be used !
[/php]
Ronald :cool:
You have a problem with the 'sendmail_from' option in your php.ini file. If you cannot change your php.ini file, try it from the outside by inserting this statement just before you issue the mail(...) command
[php]ini_set(sendmail_from, "bbheong0219@yahoo.com"); // the INI lines are to force the From Address to be used !
[/php]
Ronald :cool:
Sorry, my computer broken this few day, i have change my code to:
[PHP]$to = $email;
$subject = "Your Password";
$body = "Username: $username\nPassword: $password\n";
ini_set(sendmail_from, "bbheong0219@yahoo.com"); // the INI lines are to force the From Address to be used !
[/PHP]
But the ouput is:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 25
Error sending email
What should i do now??
Thanks..
Verify that you have SMTP running on your server.
Verify that you have SMTP running on your server.
Sorry, may i know how to verify it??
Sorry, may i know how to verify it??
Depends...what operating system are you using?
Depends...what operating system are you using?
Microsoft Windows XP... So, what should i do?? Thanks, Motoma..
Atli 5,058
Expert 4TB
If you have access to an online server it would be much simpler to test this kind of script on that, it will probbly have this set up already.
I'm assuming ofc that you are only using your localhost to test scripts you are developing, and the shipping them off somwhere else where it is used.
Microsoft Windows XP... So, what should i do?? Thanks, Motoma..
Install an SMTP server :P
Google will give you as good of a result for this as I can.
Install an SMTP server :P
Google will give you as good of a result for this as I can.
I have install an SMTP server.. What should i do to verify that i have SMTP running on my server??
No matter i have key in the username or email or not, the output is same...
Output:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 25
Error sending email
Is you firewall enabled? Is it blocking your smtp port?
Is you firewall enabled? Is it blocking your smtp port?
Thanks...
I have checking my firewall, it don't blocking my smtp port... So, what is the problem of it... Do you or someone have other scripts of forget password to let me try is whether it is work??
Just only one thing left:
Show us your PHP.INI ( in the Windows subdirectory!) settings for the following entries: - [mail function]
-
; For Win32 only.
-
SMTP = xxxxxxxxxxxxx
-
smtp_port = yy
-
-
; For Win32 only.
-
sendmail_from = zzzzzzzzzzzzzz
Ronald :cool:
Atli 5,058
Expert 4TB
I recommend you try this. It's a free SMTP server. Just install it, open it and you should be able to use the mail() function on your localhost. Free SMTP server
I would turn of any other SMTP server you might have before you use this.
Just only one thing left:
Show us your PHP.INI (in the Windows subdirectory!) settings for the following entries: - [mail function]
-
; For Win32 only.
-
SMTP = xxxxxxxxxxxxx
-
smtp_port = yy
-
-
; For Win32 only.
-
sendmail_from = zzzzzzzzzzzzzz
Ronald :cool:
This is my php.ini setting...
[mail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = me@localhost.com
I don't know what i'm doing correct or not, but i'm trying to change it as below:
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = me@localhost.com
And the code as below: -
$to = $email;
-
$subject = "Your Password";
-
$body = "Username: $username\nPassword: $password\n";
-
ini_set(sendmail_from, "me@localhost.com"); // the INI lines are to force the From Address to be used !
but the output still is the same message:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Apache2\Apache2\htdocs\forgetPassword.php on line 25
Error sending email
Thanks..
I recommend you try this. It's a free SMTP server. Just install it, open it and you should be able to use the mail() function on your localhost. Free SMTP server
I would turn of any other SMTP server you might have before you use this.
Emm.. I already install it, but i'm unable to use the mail() function on localhost.
Thanks..
Atli 5,058
Expert 4TB
Then, as was pointed out earlier, either the mail settings in your php.ini have been changed or there is a firewall blocking your SMTP server.
Your php.ini mail settings should be:
SMTP = localhost
smtp_port = 25
And there is really no way to tell you how to check the firewall because there are like million types of firewalls each with their own configurations.
You will just have to find out which one you have and find a way to unblock port 25
Then, as was pointed out earlier, either the mail settings in your php.ini have been changed or there is a firewall blocking your SMTP server.
Your php.ini mail settings should be:
SMTP = localhost
smtp_port = 25
And there is really no way to tell you how to check the firewall because there are like million types of firewalls each with their own configurations.
You will just have to find out which one you have and find a way to unblock port 25
I have go to control panel -> windows firewall -> expection -> add port
I aad the port as below:
Name: localhost
Port Number: 25
but the result is still same, i want to give up ledy..
Atli 5,058
Expert 4TB
Do you have any Anti-virus programs?
Is it possible a router is blocking the port?
Are you sure your connected to the internet!?
If you have a email account with a provider, they usually have an SMTP server box that you can address.
Suppose your email account is bbnicole@provider.com, their smtp server will be something like smtp.provider.com. You can check that from your own email client setup.
That is what you then specify in the SMTP = statement i.e.
For the sendmail_from you can then specify your own email address: - sendmail_from = bbnicole@provider.com
That works for me, I just use my provider's smtp server and don't have to install my own.
Ronald :cool:
Try this:
From the start menu, click Run.
Type in 'cmd'.
From the command prompt, type 'telnet localhost 25'.
What do you see?
Try this:
From the start menu, click Run.
Type in 'cmd'.
From the command prompt, type 'telnet localhost 25'.
What do you see?
After i type, it show me:
Connecting to localhost... Could not open connection to the host, on port 25: Connect Fail
Thanks..
If you have a email account with a provider, they usually have an SMTP server box that you can address.
Suppose your email account is bbnicole@provider.com, their smtp server will be something like smtp.provider.com. You can check that from your own email client setup.
That is what you then specify in the SMTP = statement i.e.
For the sendmail_from you can then specify your own email address: - sendmail_from = bbnicole@provider.com
That works for me, I just use my provider's smtp server and don't have to install my own.
Ronald :cool:
Sorry, how can i check whether i have a email account with a provider and how to check that from my own email client setup. Thanks..
Do you have any Anti-virus programs?
Is it possible a router is blocking the port?
Are you sure your connected to the internet!?
Yes, i used Karpersky Anti-Virus 6.0, but i don't know whether it is block the port.. Thanks..
After i type, it show me:
Connecting to localhost... Could not open connection to the host, on port 25: Connect Fail
Thanks..
This means you do not have an SMTP server running.
This is also the source of your error.
This means you do not have an SMTP server running.
This is also the source of your error.
What should i do?? I already install Free SMTP Server..Thanks..
What should i do?? I already install Free SMTP Server..Thanks..
Are you running it?
Do you have the SMTP server up on your screen?
Are you running it?
Do you have the SMTP server up on your screen?
It oledy have the shotcut in my screen.. and it can open, but it is need to used it? It's just a server, right??
I'm trying to click on it, it has a button call option,
DNS Server is autodetect
SMTP Port is standard #25
Thanks..
It oledy have the shotcut in my screen.. and it can open, but it is need to used it? It's just a server, right??
I'm trying to click on it, it has a button call option,
DNS Server is autodetect
SMTP Port is standard #25
Thanks..
You will need to keep it running in order to use mail.
You will need to keep it running in order to use mail.
How to keep it running??
ANd my outlook express cant send the mail and got error message come out, is it related??
The error message is:
The service is currently unavailable. Try again later. Account: 'Hotmail', Server: 'http://services.msn.com/svcs/hotmail/httpmail.asp', Protocol: HTTPMail, Server Response: 'Service Unavailable', Port: 0, Secure(SSL): No, Socket Error: 87, Error Number: 0x800CCCF0
Unable to poll for new messages on your HTTP server. Account: 'Hotmail', Server: 'http://services.msn.com/svcs/hotmail/httpmail.asp', Protocol: HTTPMail, Server Response: 'Service Unavailable', Port: 0, Secure(SSL): No, Socket Error: 87, Error Number: 0x800CCCF0
Thanks...
Hi All
I've been reading this thread, bcoz I had the same problem. I have followed all these instruction until Installation of Free SMTP Server. Now I have a problem when I clicked on the icon, it gives me an error. 'Internet or DNS Server Inaccessible'.
What must I do?
thanks :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kwindham |
last post by:
This program doesn't seem like it should be too hard, but I cannot
figure it out. Here is the assignment:
Password Verifier - Write a program to verify passwords, satisfying the
following...
|
by: Andrea |
last post by:
Hi,
i've installed OCS Inventory NG for inventory and it has installed
Mysql ver:
mysql Ver 14.12 Distrib 5.0.18, for Win32
now i have to make a dump for save database but don't forget the...
|
by: Kevin O'Brien |
last post by:
Hello,
I am creating a sign on screen for my application in which I want to store
the username and password in a database table. I was thinking of putting a
combo box connected to the database...
|
by: =?Utf-8?B?QW1qYWQ=?= |
last post by:
I have one question about forget password control with asp.net 2.0
we are using here Groupwise . how can i send email using group wise instead
of SMPT and how to change the setting for or i have to...
|
by: chaos |
last post by:
Hi all , i occur a problem in my forget password page as the page appear as blank page . Can anyone help me find out wt went wrong with my code.
<?php require_once('Connections/conn.php'); ?>...
|
by: whitey |
last post by:
Hi All,
The following script works when username(or email) and password are in 1 table. what i need to know is how to adjust the code to reflect that the email will be held in tbl_email and the...
|
by: ghjk |
last post by:
I'm developing web site using php and my sql. In there i want to send a mail including new password to user, when he forget his password. How can i send mail using php? Could you please help me?
|
by: harshadd |
last post by:
I have 3000+ exchange users and most of the time they forget the password and we reset it for them. again problem is this happens on phone. so no guaranty that user it self has requested to...
|
by: dxting |
last post by:
Hi
Can anyone tell me how to write the forget password function in my web page.My web page haven't publish yet. Just using it as local host. Means don't have domain yet.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |