Click to See Complete Forum and Search --> : Failing to Open Stream


GLP23
03-23-2006, 04:42 PM
ok, i just cant get this to work, your help is much appreciated, i have a form to email script that im still trying to work, the following errors are coming up:


Warning: main(/home/bay59170/public_html/include/include.php): failed to open stream: No such file or directory in /home/bay59170/public_html/contact1.php on line 33

Fatal error: main(): Failed opening required '/home/bay59170/public_html/include/include.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/lib/php4') in /home/bay59170/public_html/contact1.php on line 33


you can view it at www.baysideliving.com.au/contact1.php

the whole code is:

when it was a html page the code was:


<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheet1.css">
<title>Bayside Living - contact us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
#homebutton {position: absolute; left:135px; top:10px;}
#aboutusbutton {position: absolute; left:315px; top:10px;}
#propertiesbutton {position: absolute; left:490px; top:10px;}
#contactbutton {position: absolute; left:667px; top:10px;}
#contactbackground {position: absolute; left:5px; top:0px; z-index:-1}
#contactform {position: absolute; left:445px; top:200px; z-index:-1}
#contacttext {position: absolute; left:40px; top:150px; z-index:-1}
#contactdetails {position: absolute; left:165px; top:550px; z-index:-1}
</style>

<style type="text/css">
<!--

body{
background:url(images/contact-background2.jpg) no-repeat;
}

//-->
</style>

</head>

<body>

<?php
require_once $_SERVER['DOCUMENT_ROOT']."/include/include.php";
head("Email Me", "Email contact form");

################################################################################
#
# mail.php - general-purpose email form and script
#
# copyright June 2005 by Charles Reace
#
# This software available as open source software under the Gnu General Public
# License: http://www.gnu.org/licenses/gpl.html
#
################################################################################

################################################################################
# user-defined variables - update for your email address(es)
################################################################################

# home page for link at top of page:
$home = "http://www.baysideliving.com.au/";

# Modify the following variables to set up where emails will be sent.
# $toName will be concatenated with a "@" and then $toDomain to create
# the complete email address.
$toName = "Jodie"; # the part that goes before the @
$toDomain = "baysideliving.com.au"; # the part that comes after the @

# uncomment and edit the next two lines if you want to cc someone:
# $ccName = "name";
# $ccDomain = "domain.com";

# uncomment and edit the next two lines if you want to bcc someone:
# $bccName = "name";
# $bccDomain = "domain.com";

#################################
# end of user-defined variables #
#################################

# email address validation function
# kudos to http://iamcal.com/publish/articles/...sing_email/pdf/
function is_valid_email_address($email) {
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quoted_pair = '\\x5c\\x00-\\x7f';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
}

# Init. some variables:
$error = "";
$success = FALSE;

# process form if submitted:
if(isset($_POST['submit']))
{
foreach($_POST as $key => $val)
{
if(empty($_POST[$key]))
{
$error .= "You must enter a value for " .
ucwords(str_replace("_"," ",$key)) . ". ";
}
else
{
if(get_magic_quotes_gpc())
{
$_POST[$key] = stripslashes($val);
}
}
if($key != 'message')
{
$_POST[$key] = preg_replace('/[\r\n]/', ' ', $val);
}
}
if($_POST['email_address'] != $_POST['repeat_email'])
{
$error .= "Email Address is not the same as Repeat Email. ";
}
elseif(is_valid_email_address($_POST['email_address']) == 0)
{
$error .= "'{$_POST['email_address']}' does not appear to be a valid email address. ";
}
if(empty($error)) # no errors in input, so go ahead and email it.
{
$to = "$toName@$toDomain";
$headers = "From: ".preg_replace('/[\r\n]+/',' ', $_POST['email_address']);
if(!empty($ccName) and !empty($ccDomain))
{
$headers .= "\r\nCc: $ccName@$ccDomain";
}
if(!empty($bccName) and !empty($bccDomain))
{
$headers .= "\r\nBcc: $bccName@$bccDomain\r\n\r\n";
}
$headers .= "\r\nX-Mailer: PHP/" . phpversion();
$msg = "From {$_POST['name']} ({$_POST['email_address']})";
$msg .= "\n\n\n{$_POST['message']}";
$result = @mail($to,
stripslashes($_POST['subject']),
$msg,
$headers);
if(!$result)
{
$error = "There was an unknown error while attempting to send your email.";
}
else
{
$error = "<span style='color: #930'>Thank you. Your message has been sent.</span>";
foreach($_POST as $key => $val)
{
$_POST[$key] = "";
}
}
}
}
if(!empty($error))
{
echo "<p style='color: #c03;'>$error</p>\n";
}
?>

<h1>Email Me</h1>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method=post>
<fieldset>
<legend>Your Contact Information</legend>
<p><label for='name' style="display: block; float: left; width: 9em;">Name:</label>
<input type='text' name='name' id='name' size='30' maxlength='40'<?php
if(!empty($_POST['name']))
{
echo "value='{$_POST['name']}'";
}
?>></p>
<p><label for='email_address' style="display: block; float: left; width: 9em;">Email Address:</label>
<input type='text' name='email_address' id='email_address' size='30' maxlength='40'<?php
if(!empty($_POST['email_address']))
{
echo "value='{$_POST['email_address']}'";
}
?>></p>
<p><label for='repeat_email' style="display: block; float: left; width: 9em;">Repeat Email:</label>
<input type='text' name='repeat_email' id='repeat_email' size='30' maxlength='40'<?php
if(!empty($_POST['repeat_email']))
{
echo "value='{$_POST['repeat_email']}'";
}
?>></p>

</fieldset>
<fieldset>
<legend>Message</legend>
<p><label for='subject' style="display: block; float: left; width: 9em;">Subject:</label>
<input type='text' name='subject' id='subject' size='50' maxlength='60'<?php
if(!empty($_POST['subject']))
{
echo " value='{$_POST['subject']}'";
}
?>></p>
<p><label for='message'>Message:</label><br>
<textarea name='message' id='message' cols='60' rows='8'
style="width: 500px"><?php
if(!empty($_POST['message']))
{
echo $_POST['message'];
}
?></textarea></p>
<p style="text-align: center;"><input type='submit' name='submit' value="Send Email"></p>
</fieldset>
</form>
<?php
foot();
?>

<div id="homebutton">
<a href="index.htm">
<img src="images/index-button.jpg" border=0>
</a>
</div>

<div id="aboutusbutton">
<a href="aboutus.htm">
<img src="images/aboutus-button.jpg" border=0>
</a>
</div>

<div id="propertiesbutton">
<a href="properties.htm">
<img src="images/properties-button.jpg" border=0>
</a>
</div>

<div id="contactbutton">
<a href="contact.htm">
<img src="images/contact-button.jpg" border=0>
</a>
</div>

<div id="contactdetails">
<font style="arial" size="-1" color="#ffffff">
P.O Box 775 Drummoyne 1470
&nbsp;
&nbsp;
&nbsp;
Phone (02)9719 1123
&nbsp;
&nbsp;
&nbsp;
Fax (02)9719 1128
&nbsp;
&nbsp;
&nbsp;

<a href="mailto:enquire@baysideliving.com.au">
<font color="#ffffff">
<b>
<u>
enquire@baysideliving.com.au
</u>
</b>
</font>
</a>
</font>
</font>
<br>
<br>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;

<i>Website, graphic design and photography completed by
<a href="http://www.greenlightpromotions.com.au" target="_blank">
<font size="-1" color="#0099FF"><b>GLP</b></font></a>™</i>
</font>
</div>

</body>
</html>

chazzy
03-23-2006, 06:35 PM
it was not necessary to post all of that.

Does this file exist
/home/bay59170/public_html/include/include.php
and does PHP have permission to read/write to it? it should be 644 at min, 777 would definitely work.

GLP23
03-23-2006, 07:05 PM
no that file does not exist, i just got that code from someone on this forum as a basic form to email script so i used it and it came up with them errors, im not that familiar when it comes to PHP, can only code in ASP, now that im on a linux server i need PHP scripts, so I dont know what you mean when you refer to them numbers (644 & 777)

Markbad311
03-23-2006, 07:21 PM
well it needs to exist to open it! those number signify who is allowed to write to it. 7|7|7| each stands permissions

Markbad311
03-23-2006, 07:25 PM
It signifys if a user, group, or world is allowed to read, write, or execute. the different combinations show the server what that file or directory is allowed to do and for who. Lots of different combo's if you have an apache webserver then make it easy to change permissions. But you don't have to go that far yet because their is no file to allow permissions on.

GLP23
03-23-2006, 07:34 PM
so why would someone include that as a script for me to use without including that file also? do you have a basic form to email script handy?

Markbad311
03-23-2006, 07:37 PM
not one that will fit your needs probaly. I will have to check but there probally be too much editing for you to do not knowing PHP and all. I can check though

Markbad311
03-23-2006, 07:43 PM
Here we go make sure you find the E-Mail Address field and the subject field and modify it.


<?
$address = getenv("REMOTE_ADDR");
$form_block = "
<form method=\"post\" action=\"$SERVER[PHP_SELF]\">
<input type=\"hidden\" name=\"IP\" value=\"$address\" />
<label>Contact Name</label>
<input type=\"text\" name=\"contact\" size=\"20\" /><br /><br />
<label>Street Address</label>
<input type=\"text\" name=\"address\" size=\"40\" /><br /><br />
<label>City</label>
<input type=\"text\" name=\"city\" size=\"10\" />
<label>State</label>
<input type=\"text\" name=\"state\" size=\"20\" /><br /><br />
<label>E-mail </label>
<input type=\"text\" name=\"email\" size=\"30\" /><br /><br />
<label>Phone Number</label>
(<input type=\"text\" name=\"acode\" size=\"2\" />)
<input type=\"text\" name=\"fthree\" size=\"2\" />-
<input type=\"text\" name=\"lfour\" size=\"3\" /><br /><br />
<label>Question or Comments</label><br />
<textarea name=\"comment\" rows=\"6\" cols=\"40\"></textarea><br /><br />
Our advertising department will respond to your inquiry withinin 2 buisness days.
<input type=\"hidden\" name=\"op\" value=\"ds\" />
<input name=\"submit\" type=\"submit\" value=\"Send your request\" />
<input name=\"reset\" type=\"reset\" value=\"Reset form start again\" />
</form> ";

if ($_POST[op] != "ds") {
// they need to see the form
echo "$form_block";
} else if ($_POST[op] == "ds") {
// check value of contact
if ($_POST[contact] == "") {
$contact_err = "<span style=\"color:red;\">You must enter a contact name.</span><br />";
$send = "no";
}
// check value of address
if ($_POST[address] == "") {
$address_err = "<span style=\"color:red;\">You must enter a address.</span><br />";
$send = "no";
}
// check value of city
if ($_POST[city] == "") {
$city_err = "<span style=\"color:red;\">You must enter a City.</span><br />";
$send = "no";
}
// check value of state
if ($_POST[state] == "") {
$state_err = "<span style=\"color:red;\">You must enter a State.</span><br />";
$send = "no";
}
// check value of email
if ($_POST[email] == "") {
$email_err = "<span style=\"color:red;\">You must enter a valid E-Mail Address.</span><br />";
$send = "no";
}
// check value of acode
if ($_POST[acode] == "") {
$area_err = "<span style=\"color:red;\">You must enter a Area Code.</span><br />";
$send = "no";
}
// check value of fthree
if ($_POST[fthree] == "") {
$phone_errf = "<span style=\"color:red;\">You must enter a Phone Number.</span><br />";
$send = "no";
}
// check value of lfour
if ($_POST[lfour] == "") {
$phone_errs = "<span style=\"color:red;\">You must enter a Phone Number.</span><br />";
$send = "no";
}
if ($send != "no") {
$msg .= "Senders Ip Address:$_POST[IP]\n";
$msg .= "Contact Name:$_POST[contact]\n";
$msg .= "Street Address:$_POST[address]\n";
$msg .= "City:$_POST[city]\n";
$msg .= "State:$_POST[state]\n";
$msg .= "E-Mail Address:$_POST[email]\n";
$msg .= "Phone:$_POST[acode]";
$msg .= "-$_POST[fthree]";
$msg .= "-$_POST[lfour]\n\n\n";
$msg .= "Comments:\n\n\t$_POST[comment]\n";

//email address
$to = "advertising@eriescene.com";

//subject title
$subject = "Comments Or Requests from Erie Scene";

$mailheaders = "From:$_POST[email] <> \n";
$mailheaders .= "Reply To: $_POST[email] \n\n";

mail($to, $subject, $msg, $mailheaders);
// Display Confirmation to the user
echo "<h4>The message has been sent to the WebMaster.</h4>";
echo "<p>Contact: $_POST[contact] </p>";
echo "<p>E-Mail Address: $_POST[email]</p>";
echo "<p>Comment: $_POST[comment]</p>";
echo "<p>Delivery Status: Sent </p>";
}
else if ($send == "no") {
echo "$contact_err";
echo "$address_err";
echo "$city_err";
echo "$state_err";
echo "$email_err";
echo "$acode_err";
echo "$phonef_err";
echo "$phones_err";
}
}
?>



Have a good one

GLP23
03-23-2006, 09:44 PM
awesome, thank you very much for that, i just have that as a separate PHP file dont i? and then include a link in the form validation to the PHP file on the html page?

Markbad311
03-23-2006, 10:47 PM
this is an e-mail form. The user files it out and 'submits' it. It operates alone. provide a link to it where ever you would like but to access the form you must echo the form just add in your .php file.

<? echo "form_block"; ?>