473,386 Members | 1,969 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.

URL and Page title in PHP

114 100+
Hi Friends,

I have a simple HTML form and simple PHP code which sends the filled information at my email address. Now, I am trying to get Page URL and Page Title at my email while submitting a form alongwith the info filled by user.

Here is my HTML form:

Expand|Select|Wrap|Line Numbers
  1. <form action="emailus.php" method="POST" name="Email_Submit" class="divtext"> 
  2.  
  3.                                                 <table width="400" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
  4.                           <tr>
  5.                             <td width="47%" valign="top">First Name:</td>
  6.                             <td width="53%" valign="top">
  7.                             <input name="FirstName" type="text" id="Contact_FName" size="20"></td>
  8.                           </tr>
  9.                           <tr>
  10.                             <td valign="top">Last Name: </div></td>
  11.                             <td valign="top">
  12.                             <input name="LastName" type="text" id="Contact_LName" size="20"></td>
  13.                           </tr>
  14.                           <tr>
  15.                             <td valign="top">Your E-mail:</td>
  16.                             <td valign="top">
  17.                             <input name="Email" type="text" id="Contact_Email" size="20"></td>
  18.                           </tr>
  19.                           <tr>
  20.                             <td valign="top">Your Question:</td>
  21.                             <td valign="top">
  22.                             <textarea name="Question" rows="5" id="Question" cols="20"></textarea></td>
  23.                           </tr>
  24.                               <tr>
  25.                             <td valign="top"><input name="Submit" type="submit" value="Submit"></td></tr>
  26.  
  27.            </form>
  28.  
Here is the emailus.php code:

Expand|Select|Wrap|Line Numbers
  1. <?
  2.   $FirstName = $_POST['FirstName'];
  3.   $LastName = $_POST['LastName'];
  4.   $email = $_POST['Email'];
  5.   $question = $_POST['Question'];
  6.  
  7. $message="First Name: $FirstName \n
  8.   Last Name: $LastName \n
  9.   Email: $email \n
  10.   Your Question: $question \n ";
  11.  
  12.   mail( "deepaks85@gmail.com", "Email Us Form Submission from", "Message: $message",  "From: $email" );
  13.   header( "Location: http://www.mydomain.com/thanks.html");
  14. ?>
  15.  
I will appreciate if anyone can help me on this...

Thanks

Deepak
Feb 19 '09 #1
3 1930
dlite922
1,584 Expert 1GB
@deepaks85
Maybe i'm not sure what your asking but you can always tack on more info to where the question is for example:


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.   $question = $_POST['Question'];
  4.    $question .= "\nThis could be the page title\n"; 
  5.    $question .= "URL: mysite.com/link/to/your/page"; 
  6.  
  7.  
Is that what your asking for?

Check out $_SERVER[] on php.net to get all sorts of info on the server and file/page.


Cheers,






Dan
Feb 19 '09 #2
TheServant
1,168 Expert 1GB
As has already been said, you will need to pass the page title and address as variables in your form. I have a similar code where my title is a variable and on the page is normally echo'd as <title>...</title> but can also be sent as a variable through a hidden input in a form. To get the page url you will need the $_SERVER[] array as Dan said.
Feb 19 '09 #3
devsusen
136 100+
For the address/URL u can use $_SERVER variables, but for the title u need to pass it in a variable along with the form. Using javascript : document.title property u can fetch the title of the page and put it in a variable within the form.
Feb 20 '09 #4

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

Similar topics

6
by: the wonderer | last post by:
This is an elementary question, but I've not been able to find the answer, so here goes: I am developing a site using php. I have the html header information in a file that I include in all the...
6
by: Don Grover | last post by:
How can I get the page title into an variable to handle in my asp. Don
1
by: alex | last post by:
Hi ! I couldn't make backups with our new system using db2 8.2. Every time I trigger a backup I get this error message: BACKUP DATABASE EBUERO2 ONLINE TO "/raid/backup/ebuero2/part1",...
5
by: Maxim Izbrodin | last post by:
Hello For displaying page titles for my ASP.NET applications I use the following technique <title><%=BannerModule.PageTitle%></title where BannerModule.PageTitle is a public field of my user...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
14
by: Paul | last post by:
I want to set the page title and/or a form hidden field programatically through ASP.Net. I do not want to use something like... <% sTitle ="My Title" %> <html><title><%=sTitle%></title>..... ...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: Spondishy | last post by:
Hi, I have a fairly simple httpmodule tied in to the endrequest event of the pipeline that writes the page title to the iis log. The problem is, I have a page where the title is changed in the...
4
osward
by: osward | last post by:
I had made a table colum sortable and paging the table, following are the code // Display Event List echo "<center>"._EVENTLIST."</center><br>"; $now = Date(Y-m-d); // sort table...
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...
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
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,...
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.