473,698 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How Do I Do This?

Hi All,

I have created the beginnings of an RSVP script so that people can
confirm/decline an invitation I send via email.

When they go to the RSVP script, (www.site.com/rsvp.php), they enter their
email address in the textfield (called email). The email entered is
validated against the email address in the database. If the validation
fails, then it says "The email address was not found in the database. Please
check the email address and try again."

If validation is successful, the user is given the option to confirm or
decline the invitation. This is done via a text link.

What I would like to do is this:

One link (<a href=confirm.ph p>confirm</a>) insert the word "confirmed" in
the option field in the database, the other link (<a
href=decline.ph p>confirm</a>) inserts the word "declined" in the option
field in the database. I am using PHP to do this. Has anyone done this
before? It seems simple, however, I can't quite get my head around it.

Any help would be greatly appreciated.

Thanks In Advance,

Justin Kozuch
Founder, Dreaming in TO
Netkeepers.ca - Proud to be a Hosting Sponsor for DreaminginTO.co m
w: http://www.dreamingNOSPAMinto.com
e: ju****@dreaming NOSPAMinto.com
Jul 17 '05 #1
14 4848
I noticed that Message-ID: <3x************ *******@news20. bellglobal.com>
from Justin Kozuch contained the following:
One link (<a href=confirm.ph p>confirm</a>) insert the word "confirmed" in
the option field in the database, the other link (<a
href=decline.p hp>confirm</a>) inserts the word "declined" in the option
field in the database. I am using PHP to do this. Has anyone done this
before? It seems simple, however, I can't quite get my head around it.


You'll have to pass a variable (the row id or some other unique value)
to the pages so that they know which record to update.

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
On Monday 13 October 2003 08:43 pm, Justin Kozuch wrote:
Hi All,

I have created the beginnings of an RSVP script so that people can
confirm/decline an invitation I send via email.

When they go to the RSVP script, (www.site.com/rsvp.php), they enter their
email address in the textfield (called email). The email entered is
validated against the email address in the database. If the validation
fails, then it says "The email address was not found in the database.
Please check the email address and try again."

If validation is successful, the user is given the option to confirm or
decline the invitation. This is done via a text link.

What I would like to do is this:

One link (<a href=confirm.ph p>confirm</a>) insert the word "confirmed" in
the option field in the database, the other link (<a
href=decline.ph p>confirm</a>) inserts the word "declined" in the option
field in the database. I am using PHP to do this. Has anyone done this
before? It seems simple, however, I can't quite get my head around it.

Any help would be greatly appreciated.


I would create a single page, rsvp.php, that both produces a form for the
purpose and processes the input of the form it creates. Instead of doing
this with two steps (input address then accept or decline), I'd combine
these into a single form. Build the form with a single inputbox for the
email address, and three buttons:
1. Accept
2. Decline
3. Cancel
All three buttons submit. This avoids needing cookies or session handling
for what is really a simple one step task. Another benefit is that you can
put two links in your email, like so:
----- EXAMPLE -----
Please come to my brthday party! You can RSVP right here:
<a href="http://www.example1.co m
rs************* ***********@exa mple2.com&rsvp= accept">ACCEPT</a>

<a href="http://www.example1.co m
rs************* ***********@exa mple2.com&rsvp= decline">DECLIN E</a>
Hope to see you there!
----- EXAMPLE -----

Now, the neat thing is that you can handle everything with an SQL update
statement:

First, do your security checks. Check $_REQUEST["rsvp"] to be sure that it
is either accept or decliine, nothing else. Then check
$_REQUEST["recipient"] to be sure that it looks like an email address, is
acceptable in length and free of SQL injection code. (Part of this process
will be to "untaint" both recipient and rsvp into server-generated
variables. Let's call them $clean["rsvp"] and $clean["recipient"] to make
life easy.)

Now you can use some php that looks like this:

$query = "UPDATE Invitation_List SET rsvp = '" . $clean["rsvp"] . "' WHERE
recipient = '" . $clean["recipient"] . "'";
$result = mysql_query($qu ery);
$affected = mysql_affected_ rows( $result );
switch( $affected ) {
case 1:
echo "Thanks for the RSVP.";
break;
case 0:
echo "You've already let us know.";
break;
case -1:
echo "we were unable to locate your email address";
break;
default:
echo "should only get here if there are 2 invites to the ";
echo "same email address.";
}

Good luck. Hope this helps.
--
Don Faulkner, KB5WPM |
(This space | "All that is gold does not glitter."
unintentionally | "Not all those who wander are lost."
left blank) | -- J.R.R. Tolkien
Jul 17 '05 #3
I noticed that Message-ID: <vo************ @corp.supernews .com> from Don
Faulkner contained the following:
Please come to my brthday party! You can RSVP right here:
<a href="http://www.example1.co m
rs************ ************@ex ample2.com&rsvp =accept">ACCEPT </a>


As long as you have made sure that the email addresses in the database
are unique.
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Max
Its easier to set a url query parameter to send to the database, eg:
<a href=submit.php ?type=confirm>c onfirm</a>
<a href=submit.php ?type=decline>d ecline</a>

use $_GET(['type']) in submit.php to retrieve either "confirm" or "decline"
and then SQL "insert into" the database.

"Justin Kozuch" <ju************ @SPAMsympatico. ca> wrote in message
news:3x******** ***********@new s20.bellglobal. com...
Hi All,

I have created the beginnings of an RSVP script so that people can
confirm/decline an invitation I send via email.

When they go to the RSVP script, (www.site.com/rsvp.php), they enter their
email address in the textfield (called email). The email entered is
validated against the email address in the database. If the validation
fails, then it says "The email address was not found in the database. Please check the email address and try again."

If validation is successful, the user is given the option to confirm or
decline the invitation. This is done via a text link.

What I would like to do is this:

One link (<a href=confirm.ph p>confirm</a>) insert the word "confirmed" in
the option field in the database, the other link (<a
href=decline.ph p>confirm</a>) inserts the word "declined" in the option
field in the database. I am using PHP to do this. Has anyone done this
before? It seems simple, however, I can't quite get my head around it.

Any help would be greatly appreciated.

Thanks In Advance,

Justin Kozuch
Founder, Dreaming in TO
Netkeepers.ca - Proud to be a Hosting Sponsor for DreaminginTO.co m
w: http://www.dreamingNOSPAMinto.com
e: ju****@dreaming NOSPAMinto.com

Jul 17 '05 #5
Well if i was trying to do this i would use the following code. (should
also be valid XHTML)
<!-- validate.php -->
<?php

/* if email address isnt set it will ask for it */
if (!isset($_REQUE ST["emailAddre ss"])) {
echo '
<form method="post" action="./validate.php" />
Email Address :<br /><input type="text" name="emailAddr ess" /><br />
<input type="submit" value="Validate me" />
</form>
';
exit;
}

/* if email address is set and not empty then it checks the DB */
if (isset($_REQUES T["emailAddre ss"]) && !empty($_REQUES T["emailAddre ss"])) {

/* Mysql database connection script here */
$connect = mysql_connect(' SERVER','USER', 'PASSWORD');
$db = mysql_select_db ('DB');

/* checking for record count with that email in that has no status */
$check = mysql_query("se lect email_field from emails where email_field =
'$_REQUEST[emailAddress]' where status_field = ''");
$num = mysql_num_rows( $check);
if ($num >= 1) {
echo '
If you wish to accept the invitation click <b>"i accept"</b> if not
click <b>"i decline"</b> and your address will be removed from our
database.<br /><br />
<a
href="./setstatus.php?s tatus=yes&email ='.$_REQUEST["emailAddre ss"].'">I
Accept</a> - <a
href="./setstatus.php?s tatus=no&email= '.$_REQUEST["emailAddre ss"].'">I
Decline</a>';
}

} else {
echo 'Sorry your email address was not found on our database.';
}

?>

<!-- setstatus.php -->
<?php
/* if both variables are set then change database accordingly */
if (isset($_REQUES T["email"]) && isset($_REQUEST["status"])) {

/* Mysql database connection script here */
$connect = mysql_connect(' SERVER','USER', 'PASSWORD');
$db = mysql_select_db ('DB');

/* change their database status */
$update = mysql_query("up date TABLE set status_field =
'$_REQUEST[status]' where email_field = '$_REQUEST[email]' ");

if ($_REQUEST["status"] == 'yes') {
echo 'Thank you for accepting our invitation.';
} else {
echo 'Thank you for updating your invitation status.';
}
}
?>

Have tested on a local server and should all work fine ;)
Have fun ;)
D.Rogers

Jul 17 '05 #6
Here is the error I got when trying to get this script going:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result
resource in
/hsphere/local/home/dreaming/dreaminginto.co m/events/beta/validate.php on
line 24

I checked php.net to see if this the right syntax, and it looks ok to me....
Here is the code around line 24:

line 21: /* checking for record count with that email in that has no status
*/
line 22: $check = mysql_query("se lect email from event1list where email =
line 23: '$_REQUEST[emailAddress]' where option = ''");
line 24: $num_rows = mysql_num_rows( $check);
line 25: if ($num >= 1) {
line 26: echo '

Any ideas? It's choking on that $num_rows line, and possibly on line 22, but
I could be wrong. Hey, I'm just a novice at PHP!!!

Justin Kozuch
"Dominic Rogers" <do*@dodgydom.c om> wrote in message
news:4v******** **********@news-reader.eresmas. com...
Well if i was trying to do this i would use the following code. (should
also be valid XHTML)
<!-- validate.php -->
<?php

/* if email address isnt set it will ask for it */
if (!isset($_REQUE ST["emailAddre ss"])) {
echo '
<form method="post" action="./validate.php" />
Email Address :<br /><input type="text" name="emailAddr ess" /><br />
<input type="submit" value="Validate me" />
</form>
';
exit;
}

/* if email address is set and not empty then it checks the DB */
if (isset($_REQUES T["emailAddre ss"]) && !empty($_REQUES T["emailAddre ss"])) {
/* Mysql database connection script here */
$connect = mysql_connect(' SERVER','USER', 'PASSWORD');
$db = mysql_select_db ('DB');

/* checking for record count with that email in that has no status */
$check = mysql_query("se lect email_field from emails where email_field =
'$_REQUEST[emailAddress]' where status_field = ''");
$num = mysql_num_rows( $check);
if ($num >= 1) {
echo '
If you wish to accept the invitation click <b>"i accept"</b> if not
click <b>"i decline"</b> and your address will be removed from our
database.<br /><br />
<a
href="./setstatus.php?s tatus=yes&email ='.$_REQUEST["emailAddre ss"].'">I
Accept</a> - <a
href="./setstatus.php?s tatus=no&email= '.$_REQUEST["emailAddre ss"].'">I
Decline</a>';
}

} else {
echo 'Sorry your email address was not found on our database.';
}

?>

<!-- setstatus.php -->
<?php
/* if both variables are set then change database accordingly */
if (isset($_REQUES T["email"]) && isset($_REQUEST["status"])) {

/* Mysql database connection script here */
$connect = mysql_connect(' SERVER','USER', 'PASSWORD');
$db = mysql_select_db ('DB');

/* change their database status */
$update = mysql_query("up date TABLE set status_field =
'$_REQUEST[status]' where email_field = '$_REQUEST[email]' ");

if ($_REQUEST["status"] == 'yes') {
echo 'Thank you for accepting our invitation.';
} else {
echo 'Thank you for updating your invitation status.';
}
}
?>

Have tested on a local server and should all work fine ;)
Have fun ;)
D.Rogers

Jul 17 '05 #7

On 14-Oct-2003, "Justin Kozuch" <ju************ @SPAMsympatico. ca> wrote:
Here is the error I got when trying to get this script going:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result
resource in
/hsphere/local/home/dreaming/dreaminginto.co m/events/beta/validate.php on
line 24

I checked php.net to see if this the right syntax, and it looks ok to
me....
Here is the code around line 24:

line 21: /* checking for record count with that email in that has no
status
*/
line 22: $check = mysql_query("se lect email from event1list where email =
line 23: '$_REQUEST[emailAddress]' where option = ''");
line 24: $num_rows = mysql_num_rows( $check);
line 25: if ($num >= 1) {
line 26: echo '

Any ideas? It's choking on that $num_rows line, and possibly on line 22,
but
I could be wrong. Hey, I'm just a novice at PHP!!!


The error you are getting indicates that the MySQL query failed probably
because of a syntax error in your SQL. In this case you have two 'where'
clauses. Replace the "where option=" with "and option=".

A few notes:
1) You should never put a $_REQUEST (or $_GET or $_POST) variable directly
into an SQL statement. It's a huge security risk. You should at least use
addslashes().
2) You set $num_rows to the number of rows, then you test $num... probably
not what you want.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers)
Jul 17 '05 #8
I made the change regarding "and option=" and it's still doing the same
thing...

Justin

"Tom Thackrey" <us***********@ nospam.com> wrote in message
news:iB******** ***********@new ssvr21.news.pro digy.com...

On 14-Oct-2003, "Justin Kozuch" <ju************ @SPAMsympatico. ca> wrote:
Here is the error I got when trying to get this script going:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result
resource in
/hsphere/local/home/dreaming/dreaminginto.co m/events/beta/validate.php on line 24

I checked php.net to see if this the right syntax, and it looks ok to
me....
Here is the code around line 24:

line 21: /* checking for record count with that email in that has no
status
*/
line 22: $check = mysql_query("se lect email from event1list where email = line 23: '$_REQUEST[emailAddress]' where option = ''");
line 24: $num_rows = mysql_num_rows( $check);
line 25: if ($num >= 1) {
line 26: echo '

Any ideas? It's choking on that $num_rows line, and possibly on line 22,
but
I could be wrong. Hey, I'm just a novice at PHP!!!


The error you are getting indicates that the MySQL query failed probably
because of a syntax error in your SQL. In this case you have two 'where'
clauses. Replace the "where option=" with "and option=".

A few notes:
1) You should never put a $_REQUEST (or $_GET or $_POST) variable directly
into an SQL statement. It's a huge security risk. You should at least use
addslashes().
2) You set $num_rows to the number of rows, then you test $num... probably
not what you want.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers)

Jul 17 '05 #9


On 14-Oct-2003, "Justin Kozuch" <ju************ @SPAMsympatico. ca> wrote:
"Tom Thackrey" <us***********@ nospam.com> wrote in message
news:iB******** ***********@new ssvr21.news.pro digy.com...

On 14-Oct-2003, "Justin Kozuch" <ju************ @SPAMsympatico. ca> wrote:
Here is the error I got when trying to get this script going:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result
resource in
/hsphere/local/home/dreaming/dreaminginto.co m/events/beta/validate.php on line 24

I checked php.net to see if this the right syntax, and it looks ok to
me....
Here is the code around line 24:

line 21: /* checking for record count with that email in that has no
status
*/
line 22: $check = mysql_query("se lect email from event1list where
email = line 23: '$_REQUEST[emailAddress]' where option = ''");
line 24: $num_rows = mysql_num_rows( $check);
line 25: if ($num >= 1) {
line 26: echo '

Any ideas? It's choking on that $num_rows line, and possibly on line
22,
but
I could be wrong. Hey, I'm just a novice at PHP!!!


The error you are getting indicates that the MySQL query failed probably
because of a syntax error in your SQL. In this case you have two 'where'
clauses. Replace the "where option=" with "and option=".

A few notes:
1) You should never put a $_REQUEST (or $_GET or $_POST) variable
directly
into an SQL statement. It's a huge security risk. You should at least
use
addslashes().
2) You set $num_rows to the number of rows, then you test $num...
probably
not what you want.

I made the change regarding "and option=" and it's still doing the same
thing...

I didn't notice it before but you're also missing an = in "where
email='$_REQUES T"

I suggest the following:

$emailaddr = addslashes($_RE QUEST['emailAddress']);
$sqlstr = "select email from event1list where email='$emailad dr' and
option=''";
$check = mysql_query($sq lstr) or die("$sqlstr failed because
".mysql_error() );
$num_rows = ....

This code will display a message telling you why the query failed and show
you the expanded query.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers)
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3359
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company Order By Company ASC";
5
2751
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to $location_other I keep getting "Notice: Undefined index: location_other" referring to (!($_POST)) { $location_other = $location; } else
2
2726
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form page************************************************************ <form action="/process.php" method="get" name="formOne" id="formOne"> <select name="owner" size="6" multiple id="owner"> <option value="one">one</option> <option...
2
2546
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") || ($x=="two") || ... || ($x=="seven")) ... or 2) switch ($x){ case("one"):
0
3277
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records each!!!) Dan ==================== <style> body, table, tr, td { font-family: 'verdana'; font-size: 12px;
5
3225
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
10053
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function func1()
6
2663
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE s.nnet_produkt_storrelse.id = sv.nnet_produkt_storrelse_id AND sv.nnet_produkt_varegruppe_id = v.nnet_produkt_varegruppe_id AND sv.nnet_produkt_varegruppe_id IN ( SELECT nnet_produkt_varegruppe_id FROM nnet_produkt_varegruppe
1
2194
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
3175
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in /home/krecik/public_html/silnik.php on line 251 Line 208: print ( "error: " . mysql_error()); Line 251: session_register("uprawnienia", "zalogowany"); I can understand that sth, is wrong in line 251 after line 208 and it is logical to
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.