This topic is locked

How to pass a varchar value to a link with out single quotes

9/28/2006 6:36:39 AM
PHPRunner General questions
F
fullfusion author

I am having a problem when an email is sent to the client, to notify the client of a new database entry.

Once the client receives the email, the email contains a URL, once the client uses the URL which triggers a form with the option to approve the membership.
Currenlty, my database is keyed by an autoincrementer...but at the time of the BeforeAdd Event I do not know the ID number yet, so I am using the second field which is the contact person to find the record that was just added...
I am new at PHP so here is what I have:

Function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//********** Send email with new data ************
$headers = 'MIME-Version: 1.0' ."\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1\r\n';

$headers .= 'From: <admin@clientsdomain.com>' ."\r\n";
$email="client@clientsdomain.com";

$message ='<html>';

$message .='<body>';

$message .='<b> A new user has registered, Click the following link to approve membership: </b><br>';

$message .='<a href="http://www.clientsdomain.com/approve_member.php?contact='.$values['contact']."\r\n";;

$message .='">To Approve Member please use this link</a>';

$message .="</body>";

$message .="</html>";
$subject="New data record";
mail($email, $subject, $message, $headers);
return true;
// return true if you like to proceed with adding new record

// return false in other case


What is supposed to happen is when the client clicks on the URL, a form will open and the client will click a check box to approve the membership, but I am unable to get the record due to the single quotes:
This is how I would like it to look like(with out quotes for it to work with the Web browser):
http://www.clientsdomain.com/approve_member.php?contact=Jon Doe
But instead this is what I get:
http://www.clientsdomain.com/approve_member.php?contact='Jon Doe'
Please help, as to how I can remove the single quotes!
Is there a diffent way, maybe to query the database within the event and get the KEY which is an Integer instead ?
Thank you in advance!

J
Jane 9/28/2006

Hi,
to remove single quotes in the $values["contact"] variable use following code:

$contact = substr($values["contact"],1,strlen($values["contact"])-2);



Then use $contact variable in your code:

...

$message .='<a href="http://www.clientsdomain.com/approve_member.php?contact=';.$contact."\r\n";

...

F
fullfusion author 9/28/2006

Hi,

to remove single quotes in the $values["contact"] variable use following code:
Then use $contact variable in your code:


Jane,
Thank you very much. That did the trick and now it works.....