473,789 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

send message when keyword is submitted

6 New Member
Heres what I'd like to accomplish and I believe I have to use server side script to do it.

I have a website where there is a question and then a text field below it to type in the answer to the question. When you click submit I'd first like it to tell the user if you submitted the correct answer, and second if the correct answer is submitted I'd like an email message to be sent to me letting me know the correct answer was submitted.
Dec 10 '07 #1
3 1287
Markus
6,050 Recognized Expert Expert
Hmm, there's many ways you can do it.

But you're not so clear on where you would like to head with this;

would you like, as soon as the button is clicked, an alert to say whether the correct keyword was typed? OR would you like to submit the information to another page (or the page it is typed into) and then compare the results?

The latter is better done with php/some server side scripting and the former (with alerts) would be best done with javascript.

If you could explain a little more, then i could give you extra tips.
Dec 10 '07 #2
clai83
41 New Member
Heres what I'd like to accomplish and I believe I have to use server side script to do it.

I have a website where there is a question and then a text field below it to type in the answer to the question. When you click submit I'd first like it to tell the user if you submitted the correct answer, and second if the correct answer is submitted I'd like an email message to be sent to me letting me know the correct answer was submitted.
markus is right there are many ways to do this.

1. To do the validation of the question you do not need a server-side script, but you can use one if you want.

2. To send an e-mail you do.

The PHP could look something like this

[PHP]
<?php
session_start() ;

//I decided to user sessions to store the person who is going to answer
//the question, because I doubt you will want anonymous people
//spamming your mail box. I have a feeling that you want to restrict
//this to a few people.
$user = $_SESSION['user'];
$answer = "answer";

//check to see if the user actually submitted the answer
if (isset($_POST['answer'])) {
//INSERT some POST variable validation here
// or you can open yourself up to a lot of security vulnerabilities
if ($answer == $_POST['answer']) {
//send e-mail using mail function
//compile your e-mail message
$to = "youremail@exam ple.com";
$subject = "Correct answer";
$message = "$_SESSION['user'] answered the question correctly";
mail($to, $subject, $message);
//set a message for your user to see
echo "Correct answer. Congratulations ";
}
}
else {
echo "Incorrect answer. Please try again";
}


?>
[/PHP]

This is just the general idea, and you can make this as complicated or simple as you want.
Dec 10 '07 #3
neoseeker191
6 New Member
i'm sorry i wasnt so specific. I'd like to alert the user if they are correct as soon as submit is clicked.

maybe this will clear up some confusion:
The website is for my girlfriends christmas gift, theres a riddle to a location and she has to figure out the answer. I want to have a form where she types the answer and it tells her if its right or wrong, and when she types in the correct answer i want a message sent to my email letting me know she did. But the email message needs to be hidden because I dont want her to know it was sent.

I hope that makes more sense.
Thanks for your help.
Dec 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4196
by: ij | last post by:
Hi, I'm trying to submit an image object, along with some other text fields to another web server from within an ASP page but am stuck on getting the image to be submitted with the form. In a bit more detail: 1. When this particular page is executed, I want the server to pull an image from a db (stored as a BLOB) along with a few other text fields. This part is easy and I have no problems with it.
2
5627
by: Danny | last post by:
Hi I am trying to create links to my product pages that are genereated via cgi. The best way seems to use the search.cgi script that is used when somebody enters a search term in the websites search box. If I type in the model number, it takes you to the product page. currently the search is submitted to cgi script via the POST, but I was wondering if I can pass this modelnumber as a parameter to script via url?
1
4746
by: Nicolae Fieraru | last post by:
Hi All, I am working on a script and I have a form to a page to be submitted (POST-ed) to an external site. I need that when the user submits the form, first step is to send an email using an asp script and only after that to post the information to the web site. I can send the email but I don't know how to post the form automatically after I send the email. I think I can use javascript, but maybe there is a better way of doing it?
4
7552
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP SP2, and IIS's SMTP and WWW servers are installed. Here is the error trace: System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an...
3
1460
by: Kenneth Keeley | last post by:
Hi, We are creating an online help desk package for our staff intranet site. We would like to have a popup message (like you get when you print to a network printer) sent to the IT support staff when a user submits a new help desk problem. can this be done with ASP.net and if so could somebody show me a small sample of how to do it. Thanks Kenneth
16
3009
by: bgreer5050 | last post by:
I have a form with the following fields: UserEmail Subject Body When the form is submitted, the email is processed fine. When I try to add another field to the mm.body (mm.Body = Body.Text & Listbox1.SelectedItem.Text) the smtp.Send fails. Any ideas ?
3
3077
by: shybe | last post by:
Ok, Im trying to create a "send this article to a friend" script for my blog, Right now its sending all the articles, but I want it to only send the article in which the form is attached to.
15
1387
by: kamarajbca | last post by:
dear sir, Now I am doing the task that the index page contains the US states Map.When i am pressing on the particular state that state map will be open.I create the link to states using with Microsoft Frontpage.Now my problem is when i am clicking the county on the state map that particular county will be opened.There are 50 states in us how should i create the link to county on the state map. Please give me the coding for this in...
7
1606
by: canajien | last post by:
How can I get a php page to automatically send all the contents in an email when it is generated? I managed to hack together a script that sends an email, but it will only send the 1st record returned and I would like it to send all the records that are on the page when it is loaded. <?php $con = mysql_connect("localhost","user","pass"); if (!$con)
0
9499
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,...
0
10374
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10121
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
9969
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
8995
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
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5539
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
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.