Jump to content

[SOLVED] Converting code to a newer version of PHP on a new server


Recommended Posts

I'm new to php, so excuse my ignorance...

 

I'm trying to send an email notice to someone who has just completed my wizard, submitted their choices (which have successfully written to my database - which assigns a uinque id)

 

They are sent an email with my URL and their unique id to come read their analysis.

http://www.mywebsite.com/?D=$id

 

Format HAd worked until I changed to a new server using a newer verison of php.  Now, when the person gets their email... they see $id instead of their unique id number.

 

I've had to make several changes to my formatting... but this one has me stumped.  Heeeeelp - PLEASE.

 

I'll be glad to paste my code in if that will help.

 

Healthnut

 

 

 

 

They are sent an email with my URL and their unique id to come read their analysis.

http://www.mywebsite.com/?D=$id

 

Format HAd worked until I changed to a new server using a newer verison of php.  Now, when the person gets their email... they see $id instead of their unique id number.

The most obvious difference is likely to be register globals being disabled for security, and the use of superglobals for $_GET, $_POST, $_SESSION, etc instead.

 

However, without seeing any code, there's not much help we can offer

 

I'm new to php, so excuse my ignorance...

 

I'm trying to send an email notice to someone who has just completed my wizard, submitted their choices (which have successfully written to my database - which assigns a uinque id)

 

They are sent an email with my URL and their unique id to come read their analysis.

http://www.mywebsite.com/?D=$id

 

Format HAd worked until I changed to a new server using a newer verison of php.  Now, when the person gets their email... they see $id instead of their unique id number.

 

I've had to make several changes to my formatting... but this one has me stumped.  Heeeeelp - PLEASE.

 

I'll be glad to paste my code in if that will help.

 

Healthnut

 

 

 

 

Am at work right now... will post it in about 2 hours... Thanks guys

I'm new to php, so excuse my ignorance...

 

I'm trying to send an email notice to someone who has just completed my wizard, submitted their choices (which have successfully written to my database - which assigns a uinque id)

 

They are sent an email with my URL and their unique id to come read their analysis.

http://www.mywebsite.com/?D=$id

 

Format HAd worked until I changed to a new server using a newer verison of php.  Now, when the person gets their email... they see $id instead of their unique id number.

 

I've had to make several changes to my formatting... but this one has me stumped.  Heeeeelp - PLEASE.

 

I'll be glad to paste my code in if that will help.

 

Healthnut

 

 

 

Here's the code:

 

<?php

 

 

include ('/var/www/vhosts/mywebsite.com/httpdocs/dboptions9.inc');

 

/********SQL Database Link*********/

 

$resplink = mysql_connect($server, $dbuser, $dbpass); // Connect to MySQL

  if(!$resplink) {

    $error_number = mysql_errno();

    $error_msg = mysql_error();

    echo "MySQL error $error_number: $error_msg";

    exit;

  }

 

/********Write to the FHA Database*********/

mysql_select_db ($db); // Select database

 

$mlquery = "INSERT INTO memberList (email, f, m, u16, a16_24, a25_34, a35_44, o45, ch1a, ch1b, ch1c, ch2, ch3, ch4, ch5a, ch5b, ch6, ch7a, ch7b, ch8a, ch8b, ch8c, ch8d, ch9, ch9a, ch9ba, ch9bb, ch9bc, ch9bd, ch9be, ch9bf, ch9bg, ch9bh, ch9bi, ch9bj, ch9bk, spa, spb, spc, spd, spe, spf, spg)

VALUES ('$_POST', '$_POST[f]', '$_POST[m]', '$_POST[u16]', '$_POST[a16_24]', '$_POST[a25_34]', '$_POST[a35_44]', '$_POST[o45]', '$_POST[ch1a]', '$_POST[ch1b]', '$_POST[ch1c]', '$_POST[ch2]', '$_POST[ch3]', '$_POST[ch4]', '$_POST[ch5a]', '$_POST[ch5b]', '$_POST[ch6]', '$_POST[ch7a]', '$_POST[ch7b]', '$_POST[ch8a]', '$_POST[ch8b]', '$_POST[ch8c]', '$_POST[ch8d]', '$_POST[ch9]', '$_POST[ch9a]', '$_POST[ch9ba]', '$_POST[ch9bb]', '$_POST[ch9bc]', '$_POST[ch9bd]', '$_POST[ch9be]', '$_POST[ch9bf]', '$_POST[ch9bg]', '$_POST[chpbh]', '$_POST[ch9bi]', '$_POST[ch9bj]', '$_POST[ch9bk]', '$_POST[spa]', '$_POST[spb]', '$_POST[spc]', '$_POST[spd]', '$_POST[spe]', '$_POST[spf]', '$_POST[spg]')";

 

mysql_db_query($db, $mlquery, $resplink) or die("Error writing to memberList table");

 

$id = mysql_insert_id();

 

mysql_select_db ($db);

$autoresp = "INSERT INTO autoresp (email, permiss, level, ip)

VALUES ('$_POST', '$_POST[Y]', '$_POST[0]', '$_POST[ip]')";

mysql_db_query($db, $autoresp, $resplink) or die("Error writing to autoresp table");

 

/*  ##############  Email the analysis link ##############    */

// headers

$id = $_POST['id'];

$email =  $_POST['email'];

$subject = 'Your handwriting analysis!';

$headers = 'From: healthnut@mywebsite.com';

 

// actual message

 

$message = '

  I hope you enjoyed going through our wizard and most certainly

  hope that you will tell your friends about us:

  http://www.mywebsite.com

 

  Simply click the link below to read your handwriting analysis:

  http://www.mywebsite.com/wizard/wa.php?D=$id

 

  Thanks and I hope you had fun...

 

  Me

  ';

 

// Mail it

mail($email, $subject, $message, $headers);

 

?>

 

Try double quotes rather than single quotes around your $message value.

 

 

And what should be the value of $id?

You have:

$id = mysql_insert_id();

and

$id = $_POST['id'];

 

Thank you.. THANK YOU!  I added the " instead of ' and deleted the $id = $_POST and it worked!

 

Thanks again!

Got the $id posting the unique id reading from the database.  When I click the link:  http://www.mywebsite.com?D=23530 (unique id) it doesn't collect the stored information that's in the db and insert it into the page for viewing.  Just posts the closing html code.

 

Can someone help with this issue also?

 

Here's the code:

 

<?php 
  
/*********** Lead-in***********/
$bod = >>>BOD
<html><head><title>Your Handwriting Analysis</title></head><body>
  <center><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="600" summary="Handwriting Analysis">
  <tr><td WIDTH="80%">
  <font face="Verdana"><font color="#000066"><span style="font-size: 10pt">
  <p>I\'ve just finished analyzing the handwriting sample you submitted. And I must say, 
the writer of this sample is a most interesting person. It\'s my goal to always be 100% accurate
     using this 200 year old science.  </span></font></font>
BOD;

/*----------------- Begin Characteristic blurbs----------------*/

$ch1a_blurb = '<p><font face="Verdana"><font color="#000066">
  <font face="Verdana"><font color="#000066"><span style="font-size: 10pt">
   Oh boy... you checked "High ending strokes that go up into the air...".
  This is like a child in class holding his hand up high begging for the teacher to call his name.  
</span></font></font></p>';

/*----------------- Close blurb----------------*/

$close_blurb = '<font face="Verdana"><font color="#000066"><span style="font-size: 10pt">
    <p>If you\'re like most people who ask me for a Handwriting Analysis, you\'re a bit shocked at how accurate it really is.  
  <p>Pass this URL along to your friends:<br>
  <span style="font-size: 12pt"><b>http://www.handwritinglady.com</b></span></span></font></font>
  <br><br></td></tr></table></center></body></html>';

/*------------------  SQL Database Link -------------*/
include ('/var/www/vhosts/handwritinglady.com/httpdocs/dboptions9.inc');

$db = mysql_connect($server, $dbuser, $dbpass);	// Connect to MySQL
   if(!$db) {
     $error_number = mysql_errno();
     $error_msg = mysql_error();
     echo "MySQL error $error_number: $error_msg";
     exit;
   }
mysql_select_db($db);

if ($D) {

   $result = mysql_query("SELECT * FROM memberList WHERE id=$D");
   $myrow = mysql_fetch_array($result);

/*------------------Build Intro body ---------------*/
echo $bod;
} 
else {
echo "Sorry, I can't find anything!";
}

/*----------Build ch1 characteristics--------------*/

if ($myrow[ch1a] === 'Y') {
echo $ch1a_blurb;
} 

echo $close_blurb;
exit;
?>

You guys have been fantastic in solving my first request... thank you I will be first to admit that I am in "way over my head".  My husband has always done this for me... but he died and I'm trying to keep going!

 

When I click the link:  http://www.mywebsite.com?D=23530 (unique id) it doesn't insert the stored information from the db.

 

Nor post the the $bod statement... it just posts  "Sorry, I can't find anything!";  and the $close_blurb code.

 

 

<?php 
  
/*********** Lead-in***********/
$bod = <<<BOD
<html><head><title>Your Handwriting Analysis</title></head><body>
  <center><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="600">
  <tr><td WIDTH="80%">
  <font face="Verdana"><font color="#000066"><span style="font-size: 10pt">
  <p>MY CONTENT HERE </span></font></font>
BOD;

/*----------------- Begin Characteristic blurbs----------------*/

$ch1a_blurb = '<p>
  <font face="Verdana"><font color="#000066"><span style="font-size: 10pt"> MY CONTENT HERE </span></font>';

/*----------------- Close blurb----------------*/

$close_blurb = '<font face="Verdana"><font color="#000066"><span style="font-size: 10pt"> MY CONTENT HERE</span></font></font>
  </td></tr></table></center></body></html>';

/*------------------  SQL Database Link -------------*/
include ('/var/www/vhosts/mywebsite.com/httpdocs/dboptions9.inc');

$db = mysql_connect($server, $dbuser, $dbpass);   // Connect to MySQL
   if(!$db) {
     $error_number = mysql_errno();
     $error_msg = mysql_error();
     echo "MySQL error $error_number: $error_msg";
     exit;
   }
mysql_select_db($db);

if ($D) {

   $result = mysql_query("SELECT * FROM memberList WHERE id=$D");
   $myrow = mysql_fetch_array($result);

/*------------------Build Intro body ---------------*/
echo $bod;
} 
else {
echo "Sorry, I can't find anything!";
}

/*----------Build ch1 characteristics--------------*/

if ($myrow[ch1a] === 'Y') {
echo $ch1a_blurb;
} 

echo $close_blurb;
exit;
?>

 

(edited to add


tags)

if ($_GET['D']) {

   $result = mysql_query("SELECT * FROM memberList WHERE id=".$_GET['D']);

You might want to validate that $_GET['D'] is actually a numeric as well, to prevent SQL injection

if ($_GET['D']) {

   $result = mysql_query("SELECT * FROM memberList WHERE id=".$_GET['D']);

You might want to validate that $_GET['D'] is actually a numeric as well, to prevent SQL injection

 

 

Thanks,  I'll try that at lunch.  Is  $bod = <<<BOD  okay?

Is  $bod = <<<BOD  okay?

I don't tend to use heredoc format, but it looks syntactically OK

 

Great....  does    echo $ch1a_blurb;    need to be  echo $_GET['ch1a_blurb'];

instead. 

 

I appreciate your help so much... I am WAY OVER my head!

 

Great....  does    echo $ch1a_blurb;    need to be  echo $_GET['ch1a_blurb'];

instead. 

From what I can see in your code, you're defining $ch1a_blurb as a simple variable, not passing it through as a $_GET parameter, so echo $ch1a_blurb should work.

Great....  does    echo $ch1a_blurb;    need to be  echo $_GET['ch1a_blurb'];

instead. 

From what I can see in your code, you're defining $ch1a_blurb as a simple variable, not passing it through as a $_GET parameter, so echo $ch1a_blurb should work.

 

 

Mark, thanks again.  Definitely making progress.  It's now posting the <<<Bod and  $close_blurb  the only thing it's NOT doing is going to the db to read the ch1a choice  and then replacing with the correct info defined as $ch1a_blurb.  I'm not getting an error message telling me that it can't find the db.... but something is still screwed up.

 

/*----------Build ch1 characteristics--------------*/

 

if ($myrow[ch1a] === 'Y') {

echo $ch1a_blurb;

}

Try echoing the value of ch1a immediately prior to the if test

/*----------Build ch1 characteristics--------------*/

echo 'ch1a=['.$myrow[ch1a].']<br />';
if ($myrow[ch1a] === 'Y') {
echo $ch1a_blurb;
}

And consider changing === in the if test comparison to ==

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.