473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

data input

Hi. I am new to PHP though i have a small background in C++ (took a intro course in college). I am wondering if this is legal to do:

Expand|Select|Wrap|Line Numbers
  1. <form action="<?
  2. $name = $HTTP_POST_VARS['name'];
  3. $fromemail = $HTTP_POST_VARS['fromemail'];
  4. $subject = $HTTP_POST_VARS['subject'];
  5. $message = $HTTP_POST_VARS['message'];
  6. $date = date('M.j.y');
  7. $header = "From: $name <$fromemail>" . "Date: $date";
  8.  
  9.  
  10. if ($name == "")
  11. {
  12.     echo "<p>Please provide your name</p>";
  13. }
  14. if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $fromemail))
  15. {
  16.     $fromemail = "not provided";
  17. }
  18. if ($subject == "")
  19. {
  20.     $subject = "message from user";
  21. }
  22. if (mail("admin@blabla.com",$subject,$message,$header))
  23. {
  24.     echo "<p>Thank you for sending the email.</p>";
  25. } else {
  26.     echo "<p>Can not send the email. Please try again later.</p>";
  27. }
  28. ?>" method="post">
  29.     <p>Name:<input name="name" type="text" size="20" /></p>
  30.     <p>Subject: <input name="subject" type="text" size="30" /></p>
  31.     <p>Message: <textarea name="message" cols="35" rows="5" /></textarea></p>
  32.     <p align="left"><input type="submit" value="send" /></p>
  33.     </form>
  34.  
Also, for the
Expand|Select|Wrap|Line Numbers
  1. if (mail("admin@blabla.com",$subject,$message,$header))
  2. {
  3.     echo "<p>Thank you for sending the email.</p>";
  4. } else {
  5.     echo "<p>Can not send the email. Please try again later.</p>";
  6. }
Is there a way I can put this message in place of the forms instead of going to another page? Or would i have to use the main template and make it so the code is on a whole seperate page?

Thank you
Feb 26 '07 #1
1 1217
Motoma
3,237 Expert 2GB
Yes, if you put your form inside an echo statement, then put that inside a condition, you can effectively replace your form with the result message.
Feb 26 '07 #2

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
2
by: Tavish Muldoon | last post by:
What a pain trying to insert data into a table from a stored proc. My webform asks for 16 pieces of data - which then gets written to the database. I found this easier than the crap below...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
by: Gene | last post by:
What can I do if I want to get the result using the sql command? for example, the select command is "select Name from Employee where StaffID=10" How to get the "Name"??? dim Name as string and...
5
by: DC Gringo | last post by:
I am having a problem reading a simple update to the database. Basically I'm testing a small change to the pubs database -- changing the price of the Busy Executive's Database Guide from 19.99 to...
3
by: aurora | last post by:
This is an entry I just added to ASPN. It is a somewhat novel technique I have employed quite successfully in my code. I repost it here for more explosure and discussions. ...
0
by: amrhi | last post by:
Hy Guys , Can anybody help me ? I try to make small web database in my unit. Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to...
3
by: jonniethecodeprince | last post by:
Hi all, I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file. There are 50 Records in this file....
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
3
by: planey | last post by:
Hi, I was reading topic about setters and getters (http://www.thescripts.com/forum/thread631267.html) and wanted to ask, how they should be used? I have noticed that a general data validators suck,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.