473,800 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URL and Page title in PHP

114 New Member
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 1958
dlite922
1,584 Recognized Expert Top Contributor
@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 Recognized Expert Top Contributor
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 New Member
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
38340
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 pages using the require_once function. That is, each page includes the line <?require_once('PageStart.php')?>
6
2473
by: Don Grover | last post by:
How can I get the page title into an variable to handle in my asp. Don
1
4756
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", "/raid/backup/ebuero2/part10", "/raid/backup/ebuero2/part11", "/raid/backup/ebuero2/part12", "/raid/backup/ebuero2/part13", "/raid/backup/ebuero2/part14", "/raid/backup/ebuero2/part15", "/raid/backup/ebuero2/part16", "/raid/backup/ebuero2/part17",
5
2915
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 control. This field is initialized in Page_Load of every my page. This technique works with the exception that the title disappears every time a page is posted back. Could somebody explain me the reason, or suggest a better technique for setting page...
4
3720
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 file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
14
3487
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>..... I want to completely seperate the code from presentation. I would like to do the same thing for a value of a hidden form field but
6
4904
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
1
6533
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 java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page. I am able to call values from file in my jsp page. But as dynamic values can be any in no...
0
1348
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 page_load. The page title is changed in the page load depending on a query string id on the url. For example an ID of 1 might be a page title of "Page Title 1" An ID of 2 might be a page title of "Page Title 2"
4
2148
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 colum if(!isset($_GET)){ $page = 1; } else {
0
9691
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
9551
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
10507
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...
0
9092
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...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
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
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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

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.