Help getting information from a page

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
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Help getting information from a page

Post by nite4000 »

Hey everyone,

I was able to get my last problem fixed thx. but I have a new onw now.

I have a page that has a payment button on it and once its completed it goes to a thankyou.php now that page does send out a email. but Its not displaying the name and cost in the email but does show the code. I have tried putting it in session with no luck.

If anyone has any suggestions please let me know

Thanks
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: Help getting information from a page

Post by Ollie Saunders »

Please post the contents of thankyou.php in between [syntax=php]and[/syntax].
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: Help getting information from a page

Post by nite4000 »

Code: Select all

session_start();
include("../settings.php");
include("../layout.php");
 
memsiteheader();
 
$i = mysql_query("SELECT * FROM coupons WHERE id='{$_GET['id']}' LIMIT 1") or die(mysql_error());
$sit = mysql_fetch_array($i, MYSQL_ASSOC);
@mysql_free_result($i);
 
$usrid=$info['id'];
 
[b]$name = $sit['name'];
$cost = $sit['cost'];
$desc = $sit['coupon_desc'];
 
$c_name=$_SESSION['name'];
$c_cost=$_SESSION['cost'];[/b]
 
srand ((double) microtime( )*1000000);
$random_number = rand( );
 
 if (strlen($_POST['go'])) { 
  //SEND EMAIL
 $done = TRUE;
// multiple recipients
$to = $_POST['email'];//$_SESSION['sess_name'];  
 
// subject
$subject = 'Your Mall Purchase';
 
// message
$message = '
<html>
  <head>
    <title>Shopping Mall Purchase</title>
    <style type="text/css">
   a, a:link, a:visited, a:active {
    color: #0000ff; 
    text-decoration: none; 
    font-family: Tahoma, Verdana; 
    font-size: 11px
    }
a:hover {
    color: #0001ff;  
    font-family: Tahoma, Verdana; 
    font-size: 11px; 
    margin: 0px; 
    padding: 0px;
    }
table   { 
    border-collapse: collapse;
    }
.fullheight{
    height:100%
    }
.style1 {
    color: #FF0000
    }
.style2 {
    color: #0000FF
    }   
 
#navcontainera
{
font: normal normal 8px Verdana, Geneva, Arial, Helvetica, sans-serif;
}
 
#navlista
{
list-style: none outside none;
margin: 3px;
padding: 0px;
}
 
@media all {
#navlista {
text-align: left
}
}
 
#navlista li
{
bottom: 0px;
line-height: 2.45em;
 
margin: 0px;
padding: 2px;
position: relative;
}
 
html>body #navlista li
{
 
margin: 0 3px 0 0;
padding: 2px 0px 2px 0;
}
 
#navlista a, #navlista a:link, #navlista a:visited
{
background: #68A0D8;
border: 2px solid #5D81A5;
bottom: 2px;
color: #000000;
cursor: pointer;
height: 3.3em;
width: 143px;
margin: 3px;
padding: 3px 5px 3px 8px;
position: relative;
right: 0px;
text-decoration: none;
font-weight: bold;
font-size : 10pt;
}
 
#navlista a:hover
{
background: #ececec;
bottom: 0px;
color: #000000;
position: relative;
right: 0px;
}
 
#navlista a:active
{
background: #cdcdcd;
bottom: 0px;
color: #000000;
position: relative;
right: 0px;
}
 
#navlista li#active
{
background: #369;
bottom: 13px;
margin: 0 3px 0 0;
padding: 0;
position: relative;
}
 
html>body #navlista li#active
{
background: #000;
margin: 0 4px 0 4px;
}
 
#navlista #activea a, #navlista #activea a:link, #navlista #activea a:visited, #navlista #activea a:hover
{
background: #369;
border-bottom: none;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-top: 1px solid #000000;
bottom: 0;
color: #FFF;
cursor: text;
margin: 0;
padding: 2px 5px 0 5px;
position: relative;
right: 0;
}
 
    -->
    </style>
  </head>
  <body>
    <div>
   
    </div>
    
    <div id="body_area">
     
      
      <table width="95%">
        <tr>
          <th colspan="2">
            Mall Purchase
          </th>
        </tr>
        <tr>
          <td>
            Thank you for your purchase. Below you will find Your coupon and coupon code which you will need to redeem your coupon. Without it you will not be able to redeem it.
          </td>
         
        </tr>
       
        <tr>
          <td>
          <br>
          <Table width=60% style="height: 215px; border: 4px dashed #000000; margin-bottom: 5px;">
 
<Tr>
        <Td style=padding: 4px;>
            <table style=height: 215px; width=390><tr>
              <td style=text-align: left; width: 390px; font-weight: bold; colspan=3><span class="style1"><b>'. $name.'</b></span></td>
            </tr>
 
                <Tr>
                    <Td style="padding:4px 10px 4px 4px; text-align: center; width: 145px;" ><img src="cashout.png" width="128" height="128" style="margin-bottom: 5px;"><img src="bar.jpg" width="130" height="23"><br>
                      <br>
                      <h1 style="color: red; margin: 0px; text-align: left;">$[b]'.$cost.'[/b]</h1>
                      <p style="font-size: 10px; text-align: left;">&nbsp;</p>
 </td>
                    <Td valign=top width=100% colspan=2><h4 class="style6">[b]'.$name.'[/b] </h4>
                      <div class="style4" style=text-align: left;>'.$desc.'</div>
                     <br>
<br>
Your Coupon Code is : '.$random_number.' <p style=text-align: left; font-size:14px; padding: 0;>&nbsp;</p></td>
                </tr>
            </table>
        </td>
    </tr>
    
</table>          </td>
           <td class="info">
            ' . $_POST['subject'] . '
          </td>
        </tr>
 
 
               
        
      </table>
      
     
    </div>
 
</body>
</html>
';
 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Additional headers
//$headers .= 'To: Customer Support ' . "\r\n";
$headers .= "From: Shopping Mall \r\n";
//$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
//$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
 
// Mail it
mail($to, $subject, $message, $headers);
$done=TRUE;
 
 
}
 
 
 


the places i have in bold is either what i was added to make it work or is where i need the information to be shown.

Thanks
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: Help getting information from a page

Post by Ollie Saunders »

Remove:

Code: Select all

@mysql_free_result($i);
You only need to call that if you have problems with exceeding memory limits.

As a convenience you might prefer to say:

Code: Select all

mysql_fetch_assoc($i);
instead of:

Code: Select all

mysql_fetch_array($i, MYSQL_ASSOC);
On to solving your problem, lets start by putting this at the top of your script:

Code: Select all

ini_set('display_errors', true);
error_reporting(E_ALL & ~E_STRICT);
Please attempt to fix any errors this causes your script to display or post them here if you can't.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: Help getting information from a page

Post by Mirge »

Code: Select all

 
$i = mysql_query("SELECT * FROM coupons WHERE id='{$_GET['id']}' LIMIT 1") or die(mysql_error());
 
Never, ever use code like that. Using user input DIRECTLY in a mysql query is dangerous.

http://us.php.net/manual/en/security.da ... ection.php
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help getting information from a page

Post by califdon »

In addition to the previous comments, I don't see where memsiteheader() is defined, nor the $info array. If you have defined these elsewhere, please show us those definitions. Also it's good practice to assign your SQL string to a variable so you can analyze it for debugging, rather than constructing it inside the mysql_query call.
Post Reply