Complicated Php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adam

    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_FIL ES['upfile']['name'];
    $test = $HTTP_POST_FILE S['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("c onfig.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">Plac e 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="multip art/form-data"
    action="sell4.p hp" 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_P OST_FILES['upfile']['tmp_name']);
    exit();
    }
    if( copy($HTTP_POST _FILES['upfile']['tmp_name'],$store_dir.$te st3) )
    {
    echo("");
    }
    else
    {
    echo("Upload of ".$HTTP_POST_FI LES['upfile']['name']." to
    ".$store_di r." failed!!!!<BR>" );
    }
    @unlink($HTTP_P OST_FILES['upfile']['tmp_name']);
    ?><img src="uploads/<?php echo $filename; ?>" width="180"
    height="150">
    <input type="hidden" name="imageinpu t" value="<?php
    echo($_SESSION["login"]); echo $filename; ?>">
    </td>
    <td>
    <table border="0" cellspacing="0" cellpadding="0"
    width="350">
    <tr>
    <td width="10">&nbs p;</td>
    <td class="bullet" colspan="2"></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="10">&nbs p;</td>
    <td class="bullet" bgcolor="E7E7E7 " width="340"
    height="100" colspan="2"><?p hp echo $photodesc; ?></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="10">&nbs p;</td>
    <td class="bullet"> &nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="10">&nbs p;</td>
    <td width="70" class="bullet"> Tel.</td>
    <td class="black" width="270"><?p hp echo $adtelno;
    ?></td>
    </tr>
    <tr>
    <td width="10">&nbs p;</td>
    <td width="70" class="bullet"> Email.</td>
    <td class="black" width="270"><?p hp echo $email; ?></td>
    </tr>
    <tr>
    <td width="10">&nbs p;</td>
    <td width="70" class="bullet"> Price.</td>
    <td class="black" width="270"><?p hp 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">&nb sp;</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>
  • Ginzo

    #2
    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@h otmail.com (adam) wrote:
    [color=blue]
    >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_FIL ES['upfile']['name'];
    >$test = $HTTP_POST_FILE S['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">Plac e 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="multip art/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_P OST_FILES['upfile']['tmp_name']);
    > exit();
    >}
    > if( copy($HTTP_POST _FILES['upfile']['tmp_name'],$store_dir.$te st3) )
    >{
    > echo("");
    >}
    >else
    >{
    > echo("Upload of ".$HTTP_POST_FI LES['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="imageinpu t" value="<?php
    >echo($_SESSI ON["login"]); echo $filename; ?>">
    > </td>
    > <td>
    > <table border="0" cellspacing="0" cellpadding="0"
    >width="350">
    > <tr>
    > <td width="10">&nbs p;</td>
    > <td class="bullet" colspan="2"></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td width="10">&nbs p;</td>
    > <td class="bullet" bgcolor="E7E7E7 " width="340"
    >height="100" colspan="2"><?p hp echo $photodesc; ?></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td width="10">&nbs p;</td>
    > <td class="bullet"> &nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td width="10">&nbs p;</td>
    > <td width="70" class="bullet"> Tel.</td>
    > <td class="black" width="270"><?p hp echo $adtelno;
    >?></td>
    > </tr>
    > <tr>
    > <td width="10">&nbs p;</td>
    > <td width="70" class="bullet"> Email.</td>
    > <td class="black" width="270"><?p hp echo $email; ?></td>
    > </tr>
    > <tr>
    > <td width="10">&nbs p;</td>
    > <td width="70" class="bullet"> Price.</td>
    > <td class="black" width="270"><?p hp 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">&nb sp;</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>[/color]


    Ciao,


    Ginzo
    ---------------------------------
    War is god's way of teaching
    Americans geography
    -- Ambrose Bierce
    ---------------------------------

    Comment

    • Matthias Esken

      #3
      Re: Complicated Php

      adam wrote:
      [color=blue]
      > 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[/color]

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

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

      What, if you call the page without having POST data?
      [color=blue]
      > @unlink($HTTP_P OST_FILES['upfile']['tmp_name']);[/color]

      The temporary file will be deleted automagically at the end of the
      script.
      [color=blue]
      > if( copy($HTTP_POST _FILES['upfile']['tmp_name'],$store_dir.$te st3) )[/color]

      Why do you use $HTTP_POST_FILE S instead of $_FILES? And why do you use
      copy() instead of move_uploaded_f ile()?

      Regards,
      Matthias

      Comment

      • adamnichols45@hotmail.com

        #4
        Re: Complicated Php

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


        Matthias Esken wrote:[color=blue]
        > adam wrote:
        >[color=green]
        > > problems is i get an error on to of the varibles and the image is[/color][/color]
        not[color=blue][color=green]
        > > 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[/color]
        >
        > It may be no real help, but some parts of the code seem strange.
        >[color=green]
        > > session_start() ;
        > > $_SESSION['price'];[/color]
        >
        > What's that? This should be something like
        > $_SESSION['price'] = 0;
        >[color=green]
        > > $_SESSION['adcost']=$_POST['adcost'];[/color]
        >
        > What, if you call the page without having POST data?
        >[color=green]
        > > @unlink($HTTP_P OST_FILES['upfile']['tmp_name']);[/color]
        >
        > The temporary file will be deleted automagically at the end of the
        > script.
        >[color=green]
        > > if( copy($HTTP_POST _FILES['upfile']['tmp_name'],$store_dir.$te st3)[/color][/color]
        )[color=blue]
        >
        > Why do you use $HTTP_POST_FILE S instead of $_FILES? And why do you[/color]
        use[color=blue]
        > copy() instead of move_uploaded_f ile()?
        >
        > Regards,
        > Matthias[/color]

        Comment

        Working...