Complicated Php

This is a discussion on Complicated Php within the PHP Language forums, part of the PHP Programming Forums category; Hi guys i have this page and it brings over lots of varibles and also an image is being uploaded ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-30-2004
adam
 
Posts: n/a
Default Complicated Php

Hi guys i have this page and it brings over lots of varibles and also
an image is being uploaded into a folder on the server here.

problems is i get an error on to of the varibles and the image is not
showing BUT as soon as i refresh the varibles are showing and so is
the image i cant figure out why i would appreciate any help please


<?php
session_start();
$_SESSION['price'];
$_SESSION['filename']=$HTTP_POST_FILES['upfile']['name'];
$test = $HTTP_POST_FILES['upfile']['name'];
$test2 = $_SESSION['log'];
$test3= ($test2 .= $test);
$_SESSION['reg'];
$_SESSION['mileage'];
$_SESSION['colour'];
$_SESSION['email'];
$_SESSION['pcode'];
$_SESSION['adtelno'];
$_SESSION['adtelno2'];
$_SESSION['adcost']=$_POST['adcost'];
$_SESSION['make']=$_POST['myselect_1'];
$_SESSION['model']=$_POST['myselect_2'];
$_SESSION['photodesc']=$_POST['photodesc'];
$_SESSION['week']=$_POST['week'];

// This presumes 'config.php' is in the same directory
// as the page you are protecting - modify the path if your config.php
file is
// in a different location:
include_once("config.php");

// Check user logged in already:
checkLoggedIn("yes");
?>
<html>
<head>
<title>Carpound.Co.Uk</title>
<link href="index.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="ffffff" marginheight="0" topmargin="0" marginwidth="0"
leftmargin="0">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>&nbsp;</td>
<td width="750">
<!*********************************** centers table below
************************************>
<table border="0" cellspacing="0" cellpadding="0" width="750">
<tr>
<td><?php include "header.php" ?></td>
</tr>
<tr>
<td width="750" valign="top" bgcolor="EDEDED">
<table border="0" cellspacing="0" cellpadding="0" width="750">
<tr>
<td>&nbsp;</td>
<td class="blackb">Sell Your Car</td>
</tr>
<tr><td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0"
width="550">
<tr>
<td class="bb">Place an advert:</td>
</tr>
<tr>
<td class="black">
Below is an example of how your advert will appear on here.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><img src="images/trans.gif" alt="" width="1" height="15"
border="0"></td></tr>
<tr><td>&nbsp;</td>
<td align="center">
<table border="0" class="this3" cellspacing="0"
cellpadding="0" width="550">
<form name="myform" enctype="multipart/form-data"
action="sell4.php" method="POST">
<Tr>
<td width="200" class="this4" align="center"
valign="middle">
<?php

if( !is_dir($store_dir) )
{
echo("Specified directory is not valid... Exiting");
@unlink($HTTP_POST_FILES['upfile']['tmp_name']);
exit();
}
if( copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir.$test3) )
{
echo("");
}
else
{
echo("Upload of ".$HTTP_POST_FILES['upfile']['name']." to
".$store_dir." failed!!!!<BR>");
}
@unlink($HTTP_POST_FILES['upfile']['tmp_name']);
?><img src="uploads/<?php echo $filename; ?>" width="180"
height="150">
<input type="hidden" name="imageinput" value="<?php
echo($_SESSION["login"]); echo $filename; ?>">
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0"
width="350">
<tr>
<td width="10">&nbsp;</td>
<td class="bullet" colspan="2"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td class="bullet" bgcolor="E7E7E7" width="340"
height="100" colspan="2"><?php echo $photodesc; ?></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td class="bullet">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="70" class="bullet">Tel.</td>
<td class="black" width="270"><?php echo $adtelno;
?></td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="70" class="bullet">Email.</td>
<td class="black" width="270"><?php echo $email; ?></td>
</tr>
<tr>
<td width="10">&nbsp;</td>
<td width="70" class="bullet">Price.</td>
<td class="black" width="270"><?php echo $price; ?></td>

</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><img src="images/trans.gif" alt="" width="1" height="50"
border="0"></td></tr>
<tr><td>&nbsp;</td>
<td>

</td></tr>
<tr>
<td bgcolor="99CC00" height="40">&nbsp;</td>
<td bgcolor="99CC00" height="40" align="center">
<INPUT TYPE="image" src="images/next2.gif" name="submit">
</td></tr>
</form>
</table>
</td>
</tr>
</table>
</td>
<td>&nbsp;</td>
</tr>
</table>


</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 12-01-2004
Ginzo
 
Posts: n/a
Default Re: Complicated Php

The newly set session variables aren't intialized until the current
page is reloaded or a new page is loaded that calls upon them. One
solution is some sort of directed refresh (say a text link). Less
reliable is a META Refresh.

Best solution, when intially setting these values, create a global
counterpart (eg $_SESSION[myvariable] and $myvariable. This can be a
little code intensive for many things; however, it solves the problem
quite neatly.

You also need to bag those globals brother.


On 30 Nov 2004 12:58:32 -0800, adamnichols45@hotmail.com (adam) wrote:

>Hi guys i have this page and it brings over lots of varibles and also
>an image is being uploaded into a folder on the server here.
>
>problems is i get an error on to of the varibles and the image is not
>showing BUT as soon as i refresh the varibles are showing and so is
>the image i cant figure out why i would appreciate any help please
>
>
><?php
>session_start();
>$_SESSION['price'];
>$_SESSION['filename']=$HTTP_POST_FILES['upfile']['name'];
>$test = $HTTP_POST_FILES['upfile']['name'];
>$test2 = $_SESSION['log'];
>$test3= ($test2 .= $test);
>$_SESSION['reg'];
>$_SESSION['mileage'];
>$_SESSION['colour'];
>$_SESSION['email'];
>$_SESSION['pcode'];
>$_SESSION['adtelno'];
>$_SESSION['adtelno2'];
>$_SESSION['adcost']=$_POST['adcost'];
>$_SESSION['make']=$_POST['myselect_1'];
>$_SESSION['model']=$_POST['myselect_2'];
>$_SESSION['photodesc']=$_POST['photodesc'];
>$_SESSION['week']=$_POST['week'];
>
>// This presumes 'config.php' is in the same directory
>// as the page you are protecting - modify the path if your config.php
>file is
>// in a different location:
>include_once("config.php");
>
>// Check user logged in already:
>checkLoggedIn("yes");
>?>
><html>
><head>
> <title>Carpound.Co.Uk</title>
> <link href="index.css" rel="stylesheet" type="text/css">
></head>
>
><body bgcolor="ffffff" marginheight="0" topmargin="0" marginwidth="0"
>leftmargin="0">
><table border="0" cellspacing="0" cellpadding="0" width="100%">
> <tr>
> <td>&nbsp;</td>
> <td width="750">
><!*********************************** centers table below
>************************************>
> <table border="0" cellspacing="0" cellpadding="0" width="750">
> <tr>
> <td><?php include "header.php" ?></td>
> </tr>
> <tr>
> <td width="750" valign="top" bgcolor="EDEDED">
> <table border="0" cellspacing="0" cellpadding="0" width="750">
> <tr>
> <td>&nbsp;</td>
> <td class="blackb">Sell Your Car</td>
> </tr>
> <tr><td>&nbsp;</td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td align="center">
> <table border="0" cellspacing="0" cellpadding="0"
>width="550">
> <tr>
> <td class="bb">Place an advert:</td>
> </tr>
> <tr>
> <td class="black">
> Below is an example of how your advert will appear on here.
> </td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><img src="images/trans.gif" alt="" width="1" height="15"
>border="0"></td></tr>
> <tr><td>&nbsp;</td>
> <td align="center">
> <table border="0" class="this3" cellspacing="0"
>cellpadding="0" width="550">
> <form name="myform" enctype="multipart/form-data"
>action="sell4.php" method="POST">
> <Tr>
> <td width="200" class="this4" align="center"
>valign="middle">
> <?php
>
>if( !is_dir($store_dir) )
>{
> echo("Specified directory is not valid... Exiting");
> @unlink($HTTP_POST_FILES['upfile']['tmp_name']);
> exit();
>}
> if( copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir.$test3) )
>{
> echo("");
>}
>else
>{
> echo("Upload of ".$HTTP_POST_FILES['upfile']['name']." to
>".$store_dir." failed!!!!<BR>");
>}
>@unlink($HTTP_POST_FILES['upfile']['tmp_name']);
>?><img src="uploads/<?php echo $filename; ?>" width="180"
>height="150">
><input type="hidden" name="imageinput" value="<?php
>echo($_SESSION["login"]); echo $filename; ?>">
> </td>
> <td>
> <table border="0" cellspacing="0" cellpadding="0"
>width="350">
> <tr>
> <td width="10">&nbsp;</td>
> <td class="bullet" colspan="2"></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td width="10">&nbsp;</td>
> <td class="bullet" bgcolor="E7E7E7" width="340"
>height="100" colspan="2"><?php echo $photodesc; ?></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td width="10">&nbsp;</td>
> <td class="bullet">&nbsp;</td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td width="10">&nbsp;</td>
> <td width="70" class="bullet">Tel.</td>
> <td class="black" width="270"><?php echo $adtelno;
>?></td>
> </tr>
> <tr>
> <td width="10">&nbsp;</td>
> <td width="70" class="bullet">Email.</td>
> <td class="black" width="270"><?php echo $email; ?></td>
> </tr>
> <tr>
> <td width="10">&nbsp;</td>
> <td width="70" class="bullet">Price.</td>
> <td class="black" width="270"><?php echo $price; ?></td>
>
> </tr>
> </table>
> </td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><img src="images/trans.gif" alt="" width="1" height="50"
>border="0"></td></tr>
> <tr><td>&nbsp;</td>
> <td>
>
> </td></tr>
> <tr>
> <td bgcolor="99CC00" height="40">&nbsp;</td>
> <td bgcolor="99CC00" height="40" align="center">
> <INPUT TYPE="image" src="images/next2.gif" name="submit">
> </td></tr>
> </form>
> </table>
> </td>
> </tr>
> </table>
> </td>
> <td>&nbsp;</td>
> </tr>
></table>
>
>
></body>
></html>



Ciao,


Ginzo
---------------------------------
War is god's way of teaching
Americans geography
-- Ambrose Bierce
---------------------------------
Reply With Quote
  #3 (permalink)  
Old 12-01-2004
Matthias Esken
 
Posts: n/a
Default Re: Complicated Php

adam wrote:

> problems is i get an error on to of the varibles and the image is not
> showing BUT as soon as i refresh the varibles are showing and so is
> the image i cant figure out why i would appreciate any help please


It may be no real help, but some parts of the code seem strange.

> session_start();
> $_SESSION['price'];


What's that? This should be something like
$_SESSION['price'] = 0;

> $_SESSION['adcost']=$_POST['adcost'];


What, if you call the page without having POST data?

> @unlink($HTTP_POST_FILES['upfile']['tmp_name']);


The temporary file will be deleted automagically at the end of the
script.

> if( copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir.$test3) )


Why do you use $HTTP_POST_FILES instead of $_FILES? And why do you use
copy() instead of move_uploaded_file()?

Regards,
Matthias
Reply With Quote
  #4 (permalink)  
Old 12-02-2004
adamnichols45@hotmail.com
 
Posts: n/a
Default Re: Complicated Php

is there any differnce i need a php scripter im willing to pay please
reply


Matthias Esken wrote:
> adam wrote:
>
> > problems is i get an error on to of the varibles and the image is

not
> > showing BUT as soon as i refresh the varibles are showing and so is
> > the image i cant figure out why i would appreciate any help please

>
> It may be no real help, but some parts of the code seem strange.
>
> > session_start();
> > $_SESSION['price'];

>
> What's that? This should be something like
> $_SESSION['price'] = 0;
>
> > $_SESSION['adcost']=$_POST['adcost'];

>
> What, if you call the page without having POST data?
>
> > @unlink($HTTP_POST_FILES['upfile']['tmp_name']);

>
> The temporary file will be deleted automagically at the end of the
> script.
>
> > if( copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir.$test3)

)
>
> Why do you use $HTTP_POST_FILES instead of $_FILES? And why do you

use
> copy() instead of move_uploaded_file()?
>
> Regards,
> Matthias


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0