I need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
teksys
Forum Commoner
Posts: 34
Joined: Tue May 14, 2002 6:58 pm
Location: Denmark

I need help

Post by teksys »

I have a PHP Script which logs stuff from a application i made in Delphi. It can be defined to be used with a password, but the problem is that when i try to login through my browser it doesn't accept the password at first time. I have to put the password in twice, which kinda makes the application i've made usless since it only tries to login once...

Maybe some kind person on this forum can fix it up, or tell me what is wrong.

Code: Select all

<?php
$email="";
$file="log.txt";
$msg="blahhhhh";
$pwd="13zxid2jdx";
##################################################
#######################
$array_name_var=array(1=>"date",2=>"action",3=>"name",4=>"ip",5=>"port",6=>"usrname",7=>"password",8=>"server");
##################################################
#######################
error_reporting(0); 
IF($op != 1 && $op !=2 && !empty($HTTP_SERVER_VARS&#1111;'QUERY_STRING']))
&#123;
##################################################
#######################
function verif_email($mail)&#123; 

if (empty($mail)) &#123;return FALSE;&#125;
elseif (strlen($mail) < 6)&#123;return FALSE;&#125;
elseif (strlen($mail) > 255) &#123;return FALSE;&#125;
elseif (!ereg("@", $mail))&#123;return FALSE;&#125;
elseif (preg_match_all("/(&#1111;^a-zA-Z0-9_\@\.\-])/i", $mail, $trouve))&#123;return FALSE;&#125;
elseif (!preg_match("/^(&#1111;a-z0-9_]|\\-|\\.)+@((&#1111;a-z0-9_]|\\-)+\\.)+&#1111;a-z]&#123;2,4&#125;\$/i", $mail))&#123;return FALSE;&#125;
else&#123;return TRUE;&#125;
&#125;
###############################################
if($HTTP_SERVER_VARS&#1111;'REQUEST_METHOD']=="GET")
&#123;
$array_var=$_GET; 
&#125;
else
&#123;
$array_var=$_POST; 
&#125;
###############################################
$update="#"."\n".date("d-m-Y-H:i")."\n";

reset ($array_var);
while (list($key,$val)=each($array_var))
&#123;
$update.=$key."=>".@trim(@str_replace("*","",$val))."\n";
&#125;
if(verif_email($email))&#123;mail($email,$msg,$update);
&#125;

#########################
$fp=@fopen($file,"a+");
@fwrite($fp,$update);
@fclose($fp);
#########################

&#125;
##################################################
####################### 
IF($op != 1 && empty($HTTP_SERVER_VARS&#1111;'QUERY_STRING']))
&#123;
if($HTTP_SERVER_VARS&#1111;'QUERY_STRING']=="")
&#123;
$title="&#1111;Enter Password]";
$input="Please enter password :";

print "<HTML><HEAD><TITLE>".$title."</Title></HEAD>
<BODY BGCOLOR="E7E3E7">
<center><FORM ACTION="$PHP_SELF">
<table width="40%" cellpadding="1" cellspacing="0" border="1" bgcolor="000000" bordercolor ="000000"><br><br><br>
<tr bgcolor="94A6BD">
<td align="center">
<font color="424142" size="2" face="Verdana"><b>".$input."</b></font>
</td>
</tr>
<tr bgcolor="E7E3E7">
<td align="center">
<INPUT TYPE="password" NAME="password" SIZE="30%">
<INPUT TYPE="hidden" NAME="op" VALUE="1">
<INPUT TYPE="submit" VALUE="OK">
</td>
</tr>
</table>
</FORM></CENTER>
</BODY></HTML>";
exit(); 
&#125;
&#125;
##################################################
####################### 
IF($op==1)
&#123;
if($pwd==$pass)
&#123;
$title="Host Information";

print "<HTML>
<HEAD>
<TITLE>".$title."</Title>
<style type=text/css><!--BODY &#123;SCROLLBAR-FACE-COLOR:#006699; SCROLLBAR-HIGHLIGHT-COLOR:#000000; SCROLLBAR-SHADOW-COLOR: #000000; SCROLLBAR-ARROW-COLOR: #CCCCCC; SCROLLBAR-TRACK-COLOR: #CCCCCC; &#125; A:active &#123;COLOR: #2092B0; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none&#125; A:hover &#123;COLOR: #2092B0; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none&#125; A:link &#123;COLOR: #006699; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none&#125; A &#123;COLOR: #006699; FONT-FAMILY: sans-serif, Arial, Helvetica; TEXT-DECORATION: none&#125; --></style>
</HEAD>
<center>
<BODY BGCOLOR="E7E3E7">
<table border="1" cellpadding="4" cellspacing="0" bgcolor="94A6BD" bordercolor="black">
<tr>
<td colspan="".(count($array_name_var)+2).""><br><font style=font-size:13 face=sans-serif, Arial, Helvetica><b>PHP-Logger stuff</b><br></td>
</tr>
<tr>";
for($i=1;$i<=count($array_name_var);$i++)
&#123;
print "<td>".$array_name_var&#1111;$i]."</td>";
&#125;
echo("</tr>");
##################################################
####################### 
$file_content=(@join("",@file($file)));
$array_file=(@explode("#",$file_content));

for($i=0;$i<count($array_file);$i++)
&#123;
echo("<tr>");
$line&#1111;$i]=(explode("\n",$array_file&#1111;$i]));

for($j=0;$j<=count($array_name_var);$j++)
&#123;

if(@ereg ("(&#1111;0-9]&#123;1,2&#125;)-(&#1111;0-9]&#123;1,2&#125;)-(&#1111;0-9]&#123;4&#125;)",$line&#1111;$i]&#1111;$j])) 
&#123;
echo("<td align="center">");
echo($line&#1111;$i]&#1111;$j]);
echo("</td>");
&#125;
else
&#123;
for($s=0;$s<count($line&#1111;$i]);$s++)
&#123;
if(!empty($line&#1111;$i]&#1111;$s]) && !empty($array_name_var&#1111;$j]))
&#123;
if(stristr($line&#1111;$i]&#1111;$s],$array_name_var&#1111;$j]))
&#123;
echo("<td align="center">");
echo(str_replace("=>","",strrchr($line&#1111;$i]&#1111;$s],"=>")));
echo("</td>");
&#125;
&#125;

&#125;
&#125;
&#125;

echo("</tr>");
&#125;
exit;
&#125;
else
&#123;
$title="&#1111;invalid password]";
$input="Invalid password, try again :";

print "<HTML><HEAD><TITLE>".$title."</Title></HEAD>
<BODY BGCOLOR="E7E3E7">
<center><FORM ACTION="$PHP_SELF">
<table width="40%" cellpadding="1" cellspacing="0" border="1" bgcolor="000000" bordercolor ="000000"><br><br><br>
<tr bgcolor="94A6BD">
<td align="center">
<font color="424142" size="2" face="sans-serif, Arial, Helvetica"><b>".$input."</b></font>
</td>
</tr>
<tr bgcolor="E7E3E7">
<td align="center">
<INPUT TYPE="password" NAME="pass" SIZE="30%">
<INPUT TYPE="hidden" NAME="op" VALUE="1">
<INPUT TYPE="submit" VALUE="OK">
</td>
</tr>
</table>
</FORM></CENTER>
</BODY></HTML>";
exit(); 
&#125;
&#125;
?>
Probably just some simple error...But i cant spot it, please help me guys :D

thanks in advance.
Last edited by teksys on Sun Oct 05, 2003 11:05 pm, edited 1 time in total.
murph
Forum Commoner
Posts: 29
Joined: Fri Oct 03, 2003 1:28 pm
Location: washington

Post by murph »

its because on the form on the front page, the password field is named password. and on the if password is wrong page the name is pass. so you just have to change the input name on the first page.
User avatar
teksys
Forum Commoner
Posts: 34
Joined: Tue May 14, 2002 6:58 pm
Location: Denmark

Post by teksys »

murph wrote:its because on the form on the front page, the password field is named password. and on the if password is wrong page the name is pass. so you just have to change the input name on the first page.

Doesn't seem to fix it :cry:
Post Reply