PHP Contact Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blkshirt
Forum Newbie
Posts: 11
Joined: Sat Dec 06, 2003 8:40 pm
Location: Ohio

PHP Contact Page

Post by blkshirt »

I found some code on the web that I want to implement into my website, however I'm a newbie to PHP...

Here's the php code I'll post the question below...

Code: Select all

<?php
if($name) &#123;
$name=$_GET&#1111;'name'];
$email=$_GET&#1111;'email'];
$subject1=$_GET&#1111;'subject'];
$message=$_GET&#1111;'message'];
$ip=$_SERVER&#1111;"REMOTE_ADDR"];
$host = gethostbyaddr($_SERVER&#1111;'REMOTE_ADDR']);
$host = $ip.".".$host;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) &#123; $hour+=12; &#125;
$ts = "$hour:$min:$sec on $mon/$day/$year";
$to="you@email.com";
$subject="Moab Software Contact Form:"." $subject1";
$body="
Message from: $name
Subject: $subject1
E-mail: $email
Message: $message

Host: $host
Time: $ts";

mail($to, $subject, $body);
echo "<script>location.href="http://youhost.com/~you"</script>";
&#125;
 ?>
I understand that I need to change the value in the $to but I'm confused to the final echo statement. I was only given the php file in the zip file that I downloaded...

Or does anybody know where I can find a "contact" page that basically has the following text boxes "Name, Email, Message" and a submit button? I don't need it sent to a database, just to my email address...

Thanks for the help...

blkshirt
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

The final echo statement redirects the user to a page you specify after the e-mail has been sent. You might change that to a thank-you page, for example.
blkshirt
Forum Newbie
Posts: 11
Joined: Sat Dec 06, 2003 8:40 pm
Location: Ohio

Post by blkshirt »

microthick wrote:The final echo statement redirects the user to a page you specify after the e-mail has been sent. You might change that to a thank-you page, for example.
Thanks!
blkshirt
Forum Newbie
Posts: 11
Joined: Sat Dec 06, 2003 8:40 pm
Location: Ohio

Post by blkshirt »

Now I get this error when I try to go to the webpage: http://www.blkshirt.net/contact.php
Parse error: parse error in /home/j9d2k0/public_html/contact.php on line 263
Line 263 code is:

Code: Select all

&lt;/html&gt;
Here's the entire code php and html code...

Code: Select all

<?php
if($name) {
$name=$_GET['name'];
$email=$_GET['email'];
$subject1=$_GET['subject'];
$message=$_GET['message'];
$ip=$_SERVER["REMOTE_ADDR"];
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$host = $ip.".".$host;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) { $hour+=12; }
$ts = "$hour:$min:$sec on $mon/$day/$year";
$to="blkshirt@earthlink.net";
$subject="blkshirt.net Contact Form:"." $subject1";
$body="
Message from: $name
Subject: $subject1
E-mail: $email
Message: $message

Host: $host
Time: $ts";

mail($to, $subject, $body);
echo "<script>location.href="http://www.blkshirt.net/thank_you.html"</script>";
}
 ?>

Code: Select all

&lt;html&gt;
&lt;form&gt;

&lt;head&gt;
&lt;title&gt;blkshirt.net -- Pricing&lt;/title&gt;
&lt;link href="css/stylesheet.css" rel="stylesheet" type="text/css"&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;

&lt;body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#FFFFFF"&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;img src="images/trans.gif" width="780" height="2"&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Home';return true;" onmouseout = "window.status = '';return true;"&gt;&lt;img src="images/home.gif" width="98" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/seperator.gif" width="3" height="25"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Perry Running';return true;" onmouseout = "window.status = '';return true;"&gt;&lt;img src="images/perry_running.gif" width="138" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/seperator.gif" width="3" height="25"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;a href="http://www.blkshirt.net/forums/index.php" onmouseover = "window.status = 'Forums';return true;" onmouseout = "window.status = '';return true;"&gt;&lt;img src="images/forums.gif" width="112" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/seperator.gif" width="3" height="25"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'myMeets';return true;" onmouseout = "window.status = '';return true;"&gt;&lt;img src="images/mymeets.gif" width="106" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/seperator.gif" width="3" height="25"&gt;&lt;/td&gt;

		&lt;td&gt;
        &lt;a onmouseover="window.status = 'Pricing';return true;" onmouseout="window.status = '';return true;" href="http://www.blkshirt.net/price.html"&gt;&lt;img src="images/pricing.gif" width="93" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/seperator.gif" width="3" height="25"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'About Us';return true;" onmouseout = "window.status = '';return true;"&gt;&lt;img src="images/about_us.gif" width="101" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/seperator.gif" width="3" height="25"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Contact';return true;" onmouseout = "window.status = '';return true;"&gt;&lt;img src="images/contact.gif" width="114" height="25" border="0"&gt;&lt;/a&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;img src="images/trans.gif" width="780" height="2"&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;img src="images/sports_01.gif" width="284" height="50"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_02.gif" width="285" height="50"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_03.gif" width="211" height="50"&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;img src="images/sports_04.gif" width="284" height="50"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_05.gif" width="285" height="50"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_06.gif" width="211" height="50"&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;img src="images/sports_07.gif" width="284" height="49"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_08.gif" width="285" height="49"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_09.gif" width="211" height="49"&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0"&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;img src="images/sports_10.gif" width="284" height="50"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_11.gif" width="285" height="50"&gt;&lt;/td&gt;

		&lt;td&gt;&lt;img src="images/sports_12.gif" width="211" height="50"&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0 "bgcolor="#e6e6e6"&gt;
	&lt;tr&gt;
		&lt;td&gt;&amp;nbsp;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		
    &lt;td&gt;&amp;nbsp;
      &lt;TABLE WIDTH=780 BORDER=0 CELLPADDING=0 CELLSPACING=0&gt;
        &lt;TR&gt; 
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=29 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=22 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=61 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=620 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=45 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD COLSPAN=5&gt; &lt;IMG SRC="images/price_02.gif" WIDTH=114 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD COLSPAN=3 ROWSPAN=2&gt; &lt;IMG SRC="images/price_03.gif" WIDTH=666 HEIGHT=37 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD COLSPAN=4&gt; &lt;IMG SRC="images/contact_text.gif" WIDTH=113 HEIGHT=36 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/price_05.gif" WIDTH=1 HEIGHT=36 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=36 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD COLSPAN=3&gt; &lt;IMG SRC="images/price_06.gif" WIDTH=52 HEIGHT=13 ALT=""&gt;&lt;/TD&gt;
          &lt;TD COLSPAN=4&gt; &lt;IMG SRC="images/price_07.gif" WIDTH=683 HEIGHT=13 ALT=""&gt;&lt;/TD&gt;
          &lt;TD ROWSPAN=2&gt; &lt;IMG SRC="images/price_08.gif" WIDTH=45 HEIGHT=14 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=13 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD ROWSPAN=2&gt; &lt;IMG SRC="images/price_09.gif" WIDTH=29 HEIGHT=408 ALT=""&gt;&lt;/TD&gt;
          &lt;TD ROWSPAN=2&gt; &lt;IMG SRC="images/price_10.gif" WIDTH=22 HEIGHT=408 ALT=""&gt;&lt;/TD&gt;
          &lt;TD COLSPAN=4 ROWSPAN=2 bgcolor="#9D9EA3" valign="top"&gt; &amp;nbsp;
&lt;TABLE class=text3 cellSpacing=0 cellPadding=0 width=600 
            align=center border=0&gt;
              &lt;TR&gt;
                &lt;TD vAlign=middle align=left width=208&gt;
                  &lt;font size="1" face="Verdana"&gt;Use this form to contact 
                  blkshirt.net in regards to any questions you may have about 
                  our services.&amp;nbsp; Please use this form if you want 
                  blkshirt.net to set up your meet.&lt;/font&gt;&lt;/TD&gt;
                &lt;TD width=392&gt;
                  &lt;CENTER&gt;
                    &lt;font face="verdana" size="1"&gt;Your Name:&lt;br&gt;
                    &lt;input type="text" name="name" style="border: 1px solid #cccccc; background-color: #ffffff;"&gt;
                    &lt;br&gt;
                    &lt;br&gt;
                    Your E-mail Address:&lt;br&gt;
                    &lt;input type="text" name="email" style="border: 1px solid #cccccc; background-color: #ffffff;"&gt;
                    &lt;br&gt;
                    &lt;br&gt;
                    Subject:&lt;br&gt;
                    &lt;input type="text" name="subject" style="border: 1px solid #cccccc; background-color: #ffffff;"&gt;
                    &lt;br&gt;
                    &lt;br&gt;
                    Message:&lt;br&gt;
                    &lt;textarea name="message" cols="40" rows="10" style="border: 1px solid #cccccc; background-color: #ffffff;"&gt;&lt;/textarea&gt;
                    &lt;br&gt;
                    &lt;br&gt;
                    &lt;input name="submit" type="submit" style="border: 1px solid #cccccc; background-color: #ffffff;" value="send"&gt;
                    &lt;/font&gt; 
                  &lt;/CENTER&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/TD&gt;
          &lt;TD ROWSPAN=3&gt; &lt;IMG SRC="images/price_12.gif" WIDTH=1 HEIGHT=409 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD&gt; &lt;IMG SRC="images/price_13.gif" WIDTH=45 HEIGHT=407 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=407 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD COLSPAN=3 ROWSPAN=2&gt; &lt;IMG SRC="images/price_14.gif" WIDTH=52 HEIGHT=15 ALT=""&gt;&lt;/TD&gt;
          &lt;TD COLSPAN=3&gt; &lt;IMG SRC="images/price_15.gif" WIDTH=682 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
          &lt;TD ROWSPAN=2&gt; &lt;IMG SRC="images/price_16.gif" WIDTH=45 HEIGHT=15 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD COLSPAN=4&gt; &lt;IMG SRC="images/price_17.gif" WIDTH=683 HEIGHT=14 ALT=""&gt;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=14 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
        &lt;TR&gt; 
          &lt;TD COLSPAN=8&gt;&amp;nbsp;&lt;/TD&gt;
          &lt;TD&gt; &lt;IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=104 ALT=""&gt;&lt;/TD&gt;
        &lt;/TR&gt;
      &lt;/TABLE&gt;
      &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0 "bgcolor="#e6e6e6"&gt;
	&lt;tr&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0 "bgcolor="#555a6e"&gt;
	&lt;tr&gt;
		&lt;td width="107" height="27"&gt;&amp;nbsp;&lt;/td&gt;

		&lt;td width="52" height="27" class="footerMenu"&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Home';return true;" onmouseout = "window.status = '';return true;"&gt;HOME&lt;a/&gt;&lt;/td&gt;

		&lt;td width="109" height="27" class="footerMenu"&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Perry Running';return true;" onmouseout = "window.status = '';return true;"&gt;PERRY RUNNING&lt;/a&gt;&lt;/td&gt;

		&lt;td width="70" height="27" class="footerMenu"&gt;&lt;a href="http://www.blkshirt.net/forums/index.php" onmouseover = "window.status = 'Forums';return true;" onmouseout = "window.status = '';return true;"&gt;FORUMS&lt;/a&gt;&lt;/td&gt;

		&lt;td width="75" height="27" class="footerMenu"&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'myMeets';return true;" onmouseout = "window.status = '';return true;"&gt;MYMEETS&lt;/a&gt;&lt;/td&gt;

		&lt;td width="75" height="27" class="footerMenu"&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Pricing';return true;" onmouseout = "window.status = '';return true;"&gt;PRICING&lt;/a&gt;&lt;/td&gt;

		&lt;td width="78" height="27" class="footerMenu"&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'About Us';return true;" onmouseout = "window.status = '';return true;"&gt;ABOUT US&lt;/a&gt;&lt;/td&gt;

		&lt;td width="75" height="27" class="footerMenu"&gt;&lt;a href="javascript:void(null);" onmouseover = "window.status = 'Contact';return true;" onmouseout = "window.status = '';return true;"&gt;CONTACT&lt;/a&gt;&lt;/td&gt;

		&lt;td width="107" height="27"&gt;&amp;nbsp;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;table width="780" border="0" cellpadding="0" cellspacing="0 "bgcolor="#555a6e"&gt;
	&lt;tr&gt;
		&lt;td width="240" height="27"&gt;&amp;nbsp;&lt;/td&gt;

		&lt;td width="300" height="27" class="footerMenu"&gt;Copyright © 2003 blkshirt.com. All rights reserved.&lt;/td&gt;

		&lt;td width="240" height="27"&gt;&amp;nbsp;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

&lt;/body&gt;

&lt;/form&gt;
&lt;/html&gt;
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

echo "<script>location.href=\"http://www.blkshirt.net/thank_you.html"</script>";

See this line above?

You have to "escape" the last quotation mark after thank_you.html.

It must look like:

echo "<script>location.href=\"http://www.blkshirt.net/thank_you.html\"</script>";
blkshirt
Forum Newbie
Posts: 11
Joined: Sat Dec 06, 2003 8:40 pm
Location: Ohio

Post by blkshirt »

It works great now...

Thank you so much for your help!
Post Reply