Web Hosting Talk







View Full Version : please help with php please!!!!!!


andyxfun
08-25-2009, 06:56 AM
i'm such in a hurry right now and please don't mind if my message sounds so desperate but i really need this project done for school so i have to finish it in 4 days but i'm new to php so....
please can you tell me why doesn't my code work???

so i have these files in the Contact folder:

contact.htm
pic.jpg
contents.htm
template.htm
save.php
mail.php


so the contact.htm file uses save.php which includes at the end the mail.php

now the problem: i used opera and it says save.php cannot be accessed at that time and using firefox,nothing appears on the screen!!!...please help


save.php:

<?php


//get data:

$text=$_REQUEST['text'];
$nume=$_REQUEST['nume'];
$subiect=$_REQUEST['subiect'];
$email=$_REQUEST['email'];
$check=$_REQUEST['check'];


//java redirect function:

function java_redirect(){

echo '<script type="text/javascript">'."\n";
echo '<!--'."\n";
echo 'function Redirect()'."\n";
echo '{'."\n";
echo 'location.href = "contact.htm"'."\n";
echo '}'."\n";
echo '// -->'."\n";
echo '</script>'."\n";

}



//checking: if not ok,it will use redirect and go back

if ( empty($nume) ) {
echo "Numele nu este completat!";
java_redirect();
}

if ( empty($subiect) ) {
echo "Subiectul nu este completat!";
java_redirect();
}

if ( empty($text) ) {
echo "Mesajul nu este completat!";
java_redirect();
}

//end checking





//mail check

1. function check_email_address($email) {
2. // First, we check that there's one @ symbol, and that the lengths are right
3. if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
4. // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
5. return false;
6. }
7. // Split it into sections to make life easier
8. $email_array = explode("@", $email);
9. $local_array = explode(".", $email_array[0]);
10. for ($i = 0; $i < sizeof($local_array); $i++) {
11. if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
12. return false;
13. }
14. }
15. if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
16. $domain_array = explode(".", $email_array[1]);
17. if (sizeof($domain_array) < 2) {
18. return false; // Not enough parts to domain
19. }
20. for ($i = 0; $i < sizeof($domain_array); $i++) {
21. if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
22. return false;
23. }
24. }
25. }
26. return true;
27. }


if (!check_email_address($email)){
echo "Adresa de email este invalida!";
java_redirect();
}


if ( $check=="VRD" || $check=="vrd" ) {
echo "Codul de verificare nu este corect!";
java_redirect();
}


// load the contents of template file
$htm = file_get_contents('template.htm');

// search for the following
$search = array('%text%','%nume%','%subiect%','%email%');

// replace it with the following
$replace = array($text,$nume,$subiect,$email);

// do the actual search & replace
str_replace($search, $replace, $htm);

// print the page
echo $htm;

file_put_contents("contents.htm", $htm);

include('mail.php');
?>



and mail.php:

<?php

// example on using PHPMailer with GMAIL

include("class.phpmailer.php");
include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded

$mail = new PHPMailer();

$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port

$mail->Username = "my username"; // GMAIL username
$mail->Password = "and password"; // GMAIL password

$mail->From = "web server";
$mail->FromName = "feedback form";
$mail->Subject = "feedback";
$mail->AltBody = "folositi format html"; //Text Body
$mail->WordWrap = 50; // set word wrap

$mail->MsgHTML($body);

$mail->AddReplyTo("some","thing");

$mail->AddAddress("everything ok","first last");

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "thank you";
}

?>


i must say that the mail.php uses the phpmailer and all settings are ok,i think that the problem is save.php but i gave mail.php anyway,if it helps:)

so where is the problem?or problems...:confused::confused:

thanks very much in advance!!!:)

bear
08-25-2009, 07:32 AM
So, you don't see a problem with the section that begins with this bit?
1. function check_email_address($email) {
What PHP that you recall can begin with an unrelated number and a "."" and still work? Just so you're aware, that tells PHP tp take the number and concatenate (append) it to the string that follows...

Start by cleaning that whole section up and see if anything then works.

andyxfun
08-25-2009, 08:21 AM
<<snipped>>
thanx again,going to try that out...im using a php editor and that didn't seem to bother it...thanks very much!

andyxfun
08-25-2009, 08:36 AM
ok,tried it,it's better now,also put in some die(); after each check fail and deleted the echo $htm from the end and trying to get it working right now...:)
ill tell you the outcome later
thanks very very much anyway!!!:)

andyxfun
08-25-2009, 08:45 AM
ok,it's not working...first i repaired some problems,i deleted the image check for instance and some other problems but still not working,the same outcome as the first time:
with opera:some error,could not locate the save.php file and could not access it and with firefox nothing appears...:((
what could be the problem this time??:(

the code now:

<?php


//get data:

$text=$_REQUEST['text'];
$nume=$_REQUEST['nume'];
$subiect=$_REQUEST['subiect'];
$email=$_REQUEST['email'];


//java redirect function:

function java_redirect(){

echo '<script type="text/javascript">'."\n";
echo '<!--'."\n";
echo 'setTimeout("Redirect()",3000)'."\n";
echo 'function Redirect()'."\n";
echo '{'."\n";
echo 'location.href = "contact.htm"'."\n";
echo '}'."\n";
echo '// -->'."\n";
echo '</script>'."\n";

}



//checking: if not ok,it will use redirect and go back

if ( empty($nume) ) {
echo "Numele nu este completat!";
java_redirect();
die();
}

if ( empty($subiect) ) {
echo "Subiectul nu este completat!";
java_redirect();
die();
}

if ( empty($text) ) {
echo "Mesajul nu este completat!";
java_redirect();
die();
}

//end checking





//mail check

function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}


if (!check_email_address($email)){
echo "Adresa de email este invalida!";
java_redirect();
die();
}




// load the contents of template file
$htm = file_get_contents('template.htm');

// search for the following
$search = array('%text%','%nume%','%subiect%','%email%');

// replace it with the following
$replace = array($text,$nume,$subiect,$email);

// do the actual search & replace
str_replace($search, $replace, $htm);


file_put_contents("contents.htm", $htm);

include('mail.php');
?>


and it's all related to this save.php file i think....i won't even get to the mail.php but it gets through the email address check (it gave me the email error once so it's ok there)
so the problem should be caused by some of these lines:

/ load the contents of template file
$htm = file_get_contents('template.htm');

// search for the following
$search = array('%text%','%nume%','%subiect%','%email%');

// replace it with the following
$replace = array($text,$nume,$subiect,$email);

// do the actual search & replace
str_replace($search, $replace, $htm);


file_put_contents("contents.htm", $htm);

include('mail.php');

i can't explain it...i told you i'm just a lil php noob...:( :confused:

any idea?

D3acon
08-25-2009, 12:15 PM
What is the URL?

egiblock
08-25-2009, 01:40 PM
since you are using firefox, get the extension "firebug" and "firephp" to help you with the php code.

could you post all of the source files here the way they are now, and i'll take a poke at it.

petteyg359
08-25-2009, 03:24 PM
Add error_reporting(E_ALL); to the top of the file. Knowing what the error is can be extremely helpful with debugging.

Something that might drastically improve the reputation of your skills / knowledge would be to never name a Javascript-related function "java_something". Javascript isn't Java, nor is it even related to Java in any way other than both being programming languages.

andyxfun
08-25-2009, 03:53 PM
here you are:

template.htm:

<html>
<head>
<title>mail</title>
<style type="text/css">
.style2 {
font-size: x-large;
}
.style3 {
font-size: xx-large;
color: #008000;
}
.style4 {
font-size: x-large;
color: #008000;
}
</style>
</head>
<body>
<p><strong><span class="style2">Mail de la: </span><span class="style3">Verde</span><span class="style4">
- un site 100% reciclabil!</span></strong></p>
<p>&nbsp;</p>
<p><strong>mail de la:</strong> %nume%</p>
<p><strong>email:</strong> %email%&nbsp;</p>
<p><strong>subiect:</strong> %subiect%</p>
<p><strong>mesaj:</strong> %text%</p>
</body>
</html>

sorry about the language,ignore it,it's not english,only take a look at the script...:)

here is contact.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">

<!-- #BeginTemplate "../master.dwt" -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- #BeginEditable "doctitle" -->
<title>Contact</title>
<!-- #EndEditable -->
<link href="../styles/style2.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style1 {
text-align: left;
}
.style2 {
border-style: solid;
border-width: 0px;
}
.style3 {
color: #C0C0C0;
font-size: xx-small;
}
.style4 {
font-size: xx-small;
}
.style5 {
color: #C0C0C0;
}
</style>
</head>

<body>

<!-- Begin Container -->
<div id="container">
<!-- Begin Masthead -->
<div id="masthead">
<h1 class="style1"><a href="../reciclat_Full.png">
<img alt="reciclarea" longdesc="../un bun mod de a salva planeta" src="../reciclat_Full_small.png" width="75" height="76" class="style2" style="float: right" /><!-- MSComment="autothumbnail" xthumbnail-orig-image="file:///C:/Documents and Settings/expert/My Documents/WEBSITES/Verde/Recycle_Bin_Full.png" --></a>Verde...un
site 100% reciclabil!<a href="../reciclat_Full.png"></a></h1>
<a href="../reciclat_Full.png"></a>
<h3 class="style1">Gîndeste Verde, Traieste Verde...</h3>
<a href="../reciclat_Full.png"></a>
</div>
<!-- End Masthead -->
<!-- Begin Navigation -->
<div id="navigation">
<ul>
<li><a href="../home.htm">Acasa</a></li>
<li><a href="../about/despre.htm">Despre</a></li>
<li><a href="../edu/domenii.htm">Domenii</a></li>
<li><a href="../news/noutati.htm">Noutati</a></li>
<li><a href="../calendar/calendar.htm">Calendar</a></li>
<li><a href="../photo_gallery/galerie%20foto.htm">Galerie Foto</a></li>
<li><a href="../information_links/link-uri%20utile.htm">Link-uri</a></li>
<li><a href="../faq/intrebari%20frecvente.htm">Intrebari frecvente</a></li>
<li><a href="contact.htm">Contact</a></li>
<br>
<li>
<li>
<li><br>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<!-- End Navigation -->
<!-- Begin Content -->
<div id="content">
<!-- #BeginEditable "content" -->
<h2>Contact</h2>
<p>telefon: 0727156166 <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0771593151</p>
<p>e-mail: <a href="mailto:verde.contact@gmail.com">verde.contact@gmail.com</a> </p>
<p>&nbsp;</p>
<p>&nbsp;</p>



<form action="save.php" method="post" >
Nume:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="nume" ><br>
Adresa dvs. de email:
<input type="text" name="email" size="25" maxlength="64">
<br />
<br />
<br />
<br />
Subiect:
<input type="text" name="subiect"><br />







<br>
Mesaj:<br>
<textarea wrap="virtual" name="text" rows=10 cols=33 maxlength=300></textarea><br />
<br />
<br>

&nbsp;<input type="submit" value="Trimite!" style="width: 101px"></form>



<p>&nbsp;</p>
<!-- #EndEditable "content" --></div>
<!-- End Content -->
<!-- Begin Footer -->
<div id="footer">
<p> <a href="../home.htm"><span class="style4">Acasa</span></a><span class="style4"> |
<a href="../about/despre.htm">Despre</a> |
<a href="../news/noutati.htm">Noutati</a> |
<a href="../calendar/calendar.htm">Calendar</a>
| <a href="../photo_gallery/galerie%20foto.htm">Galerie Foto</a> |
<a href="../information_links/link-uri%20utile.htm">Link-uri</a> |
<a href="../faq/intrebari%20frecvente.htm">Întrebari frecvente</a> | </span>
<span class="style4"><a href="contact.htm">Contact</a></span></p>
<a href="../tos.htm" class="style5"><span class="style4">termeni si conditii</span></a> | </span>
<span class="style3">Copyright www.verde.22web.net</span>
</div>
<!-- End Footer --></div>
<!-- End Container -->

</body>

<!-- #EndTemplate -->

</html>



and as you can see,the address is http://www.verde.22web.net
from the homepage,you go to the contact area...


here is save.php:

<?php


//get data:

$text=$_REQUEST['text'];
$nume=$_REQUEST['nume'];
$subiect=$_REQUEST['subiect'];
$email=$_REQUEST['email'];


//java redirect function:

function java_redirect(){

echo '<script type="text/javascript">'."\n";
echo '<!--'."\n";
echo 'setTimeout("Redirect()",3000)'."\n";
echo 'function Redirect()'."\n";
echo '{'."\n";
echo 'location.href = "contact.htm"'."\n";
echo '}'."\n";
echo '// -->'."\n";
echo '</script>'."\n";

}



//checking: if not ok,it will use redirect and go back

if ( empty($nume) ) {
echo "Numele nu este completat!";
java_redirect();
die();
}

if ( empty($subiect) ) {
echo "Subiectul nu este completat!";
java_redirect();
die();
}

if ( empty($text) ) {
echo "Mesajul nu este completat!";
java_redirect();
die();
}

//end checking





//mail check

function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}


if (!check_email_address($email)){
echo "Adresa de email este invalida!";
java_redirect();
die();
}




// load the contents of template file
$htm = file_get_contents('template.htm');

// search for the following
$search = array('%text%','%nume%','%subiect%','%email%');

// replace it with the following
$replace = array($text,$nume,$subiect,$email);

// do the actual search & replace
str_replace($search, $replace, $htm);


file_put_contents("contents.htm", $htm);

include('mail.php');
?>


and here is mail.php:

<?php

// example on using PHPMailer with GMAIL

include("class.phpmailer.php");
include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded

$mail = new PHPMailer();

$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port

$mail->Username = "verde.contact@gmail.com"; // GMAIL username
$mail->Password = "my password...:)"; // GMAIL password

$mail->From = "verde.22web.net";
$mail->FromName = "feedback form";
$mail->Subject = "feedback";
$mail->AltBody = "folositi format html"; //Text Body
$mail->WordWrap = 50; // set word wrap

$mail->MsgHTML($body);

$mail->AddReplyTo("verde.contact@gmail.com","verde");

$mail->AddAddress("verde.contact@gmail.com","first last");

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "thank you";
}

?>




so can you figure it out??

it just freezes and nothing happens,no mail arrives...:(

and for editing php,i use NuSphere PhpED




please help me....and thanx!:)

andyxfun
08-25-2009, 03:56 PM
and yes,i'll try to add the error report to it in the morning!
thanks!

bear
08-25-2009, 04:21 PM
i really need this project done for school so i have to finish it in 4 days but i'm new to php
So this is homework?

gewthen
08-25-2009, 04:35 PM
If this is for school then asking for help here constitutes cheating. Accept whatever grade you get from doing the work alone without help.

mattle
08-25-2009, 04:51 PM
I disagree...would you allow yourself to get fired from your job because you couldn't solve a programming issue you were assigned without help?

I've been doing this for over a decade, and I've ALWAYS got my head in some manual, API doc, forum, newsgroup, etc. There's no way that anyone reads a PHP book, commits every function and syntax to memory and then programs in a vacuum for the rest of his/her life.

Half the battle is learning how to get help when you need it. The other half is understanding the help you get so you don't come back next time asking the same questions.

@andyxfun: You seem like you're in over your head here...and since your first post was blowing up on some line numbers prefacing your code, I'm inclined to believe you've been cutting and pasting scripts you don't understand.

You got a long way to go if you're going to 1) get this done on time and 2) understand what you're doing here. Start with the error reporting suggestion. I would also print out some explanatory debugging information right before every "return false;" statement. You should also read up on the difference between http://us2.php.net/die and http://us2.php.net/exit

EDIT: A perfect example. After posting, I re-checked the docs and found out that die() and exit() are equivalent in PHP...not so in Perl. Had I not rechecked, surely someone here would have reminded me :)

gewthen
08-25-2009, 09:20 PM
.

I disagree...would you allow yourself to get fired from your job because you couldn't solve a programming issue you were assigned without help?

The difference is that this is for a class. Academics and classes are not part of the professional world. Most classes require no help (at least in all the classes I took) from any unapproved outside sources.



I've been doing this for over a decade, and I've ALWAYS got my head in some manual, API doc, forum, newsgroup, etc. There's no way that anyone reads a PHP book, commits every function and syntax to memory and then programs in a vacuum for the rest of his/her life.


I doubt you have been taking college level classes or higher for ten years. If however you are referring to getting help for problem you find while in a job, then I agree seeking help anywhere is fine.



Half the battle is learning how to get help when you need it. The other half is understanding the help you get so you don't come back next time asking the same questions.


I agree in a professional non-academic setting, but in an academic setting if you learn that you need help and you go out and ask for the answer, then I don't know what else to call that other than cheating.



@andyxfun: You seem like you're in over your head here...and since your first post was blowing up on some line numbers prefacing your code, I'm inclined to believe you've been cutting and pasting scripts you don't understand.


You got a long way to go if you're going to 1) get this done on time and 2) understand what you're doing here. Start with the error reporting suggestion. I would also print out some explanatory debugging information right before every "return false;" statement. You should also read up on the difference between http://us2.php.net/die and http://us2.php.net/exit

EDIT: A perfect example. After posting, I re-checked the docs and found out that die() and exit() are equivalent in PHP...not so in Perl. Had I not rechecked, surely someone here would have reminded me :)

nickia
08-25-2009, 10:24 PM
.



The difference is that this is for a class. Academics and classes are not part of the professional world. Most classes require no help (at least in all the classes I took) from any unapproved outside sources.




I doubt you have been taking college level classes or higher for ten years. If however you are referring to getting help for problem you find while in a job, then I agree seeking help anywhere is fine.




I agree in a professional non-academic setting, but in an academic setting if you learn that you need help and you go out and ask for the answer, then I don't know what else to call that other than cheating.

I don't want to sound harsh here but your logic seems absurd. Let's say if you are studying math and got stuck in a question and ask someone for help, and you would call that cheating? Students have been doing this for century. I hope you are not suggesting people should lock themselves into a confined room and figure out everything by themselves.

egiblock
08-25-2009, 10:38 PM
if you were working on a test, i'd say you are cheating. if you are doing homework, then there is a thin line there..

just my 2cents..

i'm finishing my masters degree, and if it wasn't' for forums like this, i wouldn't be where i am today.

egiblock
08-25-2009, 10:42 PM
could be my own install problem because i don't have a mail server on my test machine, but:


[25-Aug-2009 22:41:25] PHP Warning: include(class.phpmailer.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:\wamp\www\test1\mail.php on line 5

[25-Aug-2009 22:41:25] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'class.phpmailer.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\test1\mail.php on line 5

[25-Aug-2009 22:41:25] PHP Warning: include(class.smtp.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:\wamp\www\test1\mail.php on line 6

[25-Aug-2009 22:41:25] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'class.smtp.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\test1\mail.php on line 6

[25-Aug-2009 22:41:25] PHP Fatal error: Class 'PHPMailer' not found in C:\wamp\www\test1\mail.php on line 8

petteyg359
08-26-2009, 12:42 AM
could be my own install problem because i don't have a mail server on my test machine, but:


[25-Aug-2009 22:41:25] PHP Warning: include(class.phpmailer.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:\wamp\www\test1\mail.php on line 5

[25-Aug-2009 22:41:25] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'class.phpmailer.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\test1\mail.php on line 5

[25-Aug-2009 22:41:25] PHP Warning: include(class.smtp.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:\wamp\www\test1\mail.php on line 6

[25-Aug-2009 22:41:25] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'class.smtp.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\test1\mail.php on line 6

[25-Aug-2009 22:41:25] PHP Fatal error: Class 'PHPMailer' not found in C:\wamp\www\test1\mail.php on line 8


Seriously, at least download the effing library the code includes. A simple 2-second Google for PHPMailer isn't hard. Don't act like those errors are the fault of the code...

andyxfun
08-26-2009, 01:47 AM
ok so now my reply:
i haven't inserted the error_reporting(E_ALL); at the top of the page yet (i'll do that next) but i feel like i need to post a reply down here:
this is not homework,nor job...i tend to take it like something in-between: as i said before it's a project: there is some kind of contest at school at the end of the summer vacation and it's all about ecologic websites.there are no age categories so i have a disadvantage from the very begining...:(
and to tell you why i sound like a noob in so many ways: because i am...no,really i am! i just started learning php from tutorials and examples as before this i just worked with simple html websites done for fun,for me and my friends...so php is relatively new for me and javascript is...more than new,something yet undiscovered so sorry about the "java something" name
and about the numbers and points,yes,you are right,i did copy-and-paste that code because it was far over my level to make a mail address checker and i know that the "." concatenates two strings but i just didn't saw those...(d.a.m.n) i use this NuSphere which is really great php editor and has those numbered rows that help alot but heck...i didn't saw the others,sorry

and now for the contest,you'll say i'm cheating but i don't think so,anyway it's not something important,just formal stuff,no prizes but still...and i must say:these kind of forums,net tutorials and practicing my skills is my way of learning...and yes,this forum has helped me much and i am grateful for this,but still help does not necessary mean cheating as i am learning with the help of others!:D

so thanks very much!

and i'm going to post the rest of the problems in a minute!

cheers!

andyxfun
08-26-2009, 02:01 AM
look,i just inserted the error_reporting(E_ALL); at the top of the save.php page,right?
like right after the <?php and before andy code?nothing happens,the same error in opera and the same nothing in firefox...where should error_reporting(E_ALL); shouw me the possible errors?or should i assign it to some varible like my $htm from the code and save it to some page?...

ps:if it helps,i'll try to get firebug and firephp...:(

:bawling:

gewthen
08-26-2009, 02:37 AM
I don't want to sound harsh here but your logic seems absurd. Let's say if you are studying math and got stuck in a question and ask someone for help, and you would call that cheating? Students have been doing this for century. I hope you are not suggesting people should lock themselves into a confined room and figure out everything by themselves.

Wrote this late at night, so there are probably several typos and mistakes....

I don't know whether the universities or high schools you went to had honor codes, but the places where I went to (highschool, undergraduate, and graduate school) all pretty much said that if the professor did not explicitly allow outside help, and you seek outside help from students or any other sources other than the professor, the book, and class notes (and its not a collaborative assignment) then you are cheating and if caught then various things would happen (e.g. a three time rule, announcing to everyone that you cheated, or expulsion). Granted its the decision of the professor, but in this case I perhaps wrongly assumed such radically high standards that I was required to face. Academic work at the undergraduate level and most graduate level course work are all YOUR OWN work and nothing but your work (not counting research, and approved sources). If you have to seek out other sources not provided to even get a passing grade then the class is over your head. Another possibility is that your professors are lazy and which case everyone does it to some degree. In this instance you should really go somewhere else where the professors really do care and not just given an appearance of caring. When it comes to cheating, if you find additional information that gives you information to form an answer, then its possibly not cheating. However if your professor is too lazy to come up with his own questions and gets them from a book you find in the library and the answers also exist in the book, then you've just cheated.

As for your math question example, yes asking other students for help on a math question is cheating because students almost always give answers to each other without explanations. Even with explanations there is no guarantee that the student understands why the answer is the answer; he is in a rush to get it completed more than to gain understanding. Moreover even asking whether a question is right or wrong before it is graded is cheating if an answer is given. I had one Math professor who wouldn't budge at helping me unless I got to a certain depth into a problem. Such an attitude was annoyingly helpful.

In some cases the professor allows collaboration among students in the class for the homework in which case discussion is not cheating, but there is no way of knowing that when someone asks for an answer to a homework problem in some form. Therefore It would be best not to answer than to be a potential facilitator of cheating. What I've said comes from that assumption that "I don't know whether giving an answer would cause the student to cheat." and so I assume I would. I assume he is seeking to cheat just to get the answer and move on with the assignment. I don't mean for the student to lock himself up in a room, but perhaps that room should be confined to his professor and the people that are allowed to go in it. I really doubt the professor would allow the whole world (by posting the question on the internet) to be allowed in such a room.

I would also mention that one of the schools I went to did a statistical analysis of code between all students (current and past). If there were statically identical code you would be charged with cheating. So students avoided looking at each others code to prevent a possibility of writing too similar code. You couldn't share solutions in the detail sense, and so getting help from each other wasn't very helpful. Getting code from forums was an automatic cheating if some other student got the same code or it was used in the past and so, as far as I know, no one bothered posting questions about code problems.

Some classes have homeworks/labs be 50% or more of the grade and so by giving answers your giving an unfair advantage to the student. If student A asks a question to a forum of experts and gets answer E and submits E as his work and students B, C don't get the expert answer E, but tried on their own, then B and C are at an unfair disadvantage. B and C realize that to get grades like A they too must ask questions they have difficulty with to a forum of experts. The two ask the questions to the expert forum and are given answers and so their grade becomes how well the community can help the students on questions that are difficult more than the personal ability of the student. Or it becomes how well the student can find the best forum or goggle the best, or formulate the assigned question best. You can't stop the student from initiating this behavior, but it is your complete decision to whether you want to harm his education and the educational system. It is better to fail at something while following the rules and know one's limits than to go forward as a cheater who has deceived himself or others of believing he has more knowledge and skills than what he actually possesses.

You really do learn more by banging your head against a problem for hours, days, or weeks until a solution comes. It isn't always fun, but it is ultimately more worthwhile and more learning comes from it. However as a paid professional it is usually considered a waste of time not to seek out an answer when someone else has answered it, but that's a world I'm not talking about.

BTW, this all comes from 10+ years involved in higher education, having never asked a single question in any form for anything.

gewthen
08-26-2009, 03:01 AM
look,i just inserted the error_reporting(E_ALL); at the top of the save.php page,right?
like right after the <?php and before andy code?nothing happens,the same error in opera and the same nothing in firefox...where should error_reporting(E_ALL); shouw me the possible errors?or should i assign it to some varible like my $htm from the code and save it to some page?...

ps:if it helps,i'll try to get firebug and firephp...:(

:bawling:

The fact that you are making a distinction between PHP errors in Firefox and Opera suggests you don't fully understand what PHP is and what is going on. Go to your professor with your problem since you seem to be missing some of the fundamentals.

Error codes are usually, but not always, unique to the particular code you are running, so I cannot give you possible error messages. All I can say is for you to read the error message codes, read the appropriate manual page and then go from there.

Coding is fun, but having problems is expected when first learning any programming language. Identifying what about the errors message you don't understand might reveal the answers to your problems or at least give you a first step. Scan your code character by character and if you see a character that you don't understand, then it means you don't fully understand the syntax. If you understand the syntax then describe what each line is suppose to do. If you can't do that then you're having problems with understanding programming concepts or the PHP library.

Have Fun.

andyxfun
08-26-2009, 04:24 AM
ok,ok,i get it...i have to learn more...so if there is no solution provided to me than i might call this thread closed! thank you very much for the help provided,if there are any other problems,i shall open up another thread regarding that specific issue. thanks again and keep up the good work!
:)

rasin
08-26-2009, 05:23 AM
in save.php

function java_redirect(){

echo '<script type="text/javascript">'."\n";
echo '<!--'."\n";
echo 'setTimeout("Redirect()",3000)'."\n";
echo 'function Redirect()'."\n";
echo '{'."\n";
echo 'location.href = "contact.htm"'."\n";
echo '}'."\n";
echo '// -->'."\n";
echo '</script>'."\n";

}


why this line
echo '<!--'."\n";
and
echo '// -->'."\n";

remove that and try
actually those will result html comment and nothing displayed in the page

hope it helps you
Rasin

mattle
08-26-2009, 06:18 AM
.



The difference is that this is for a class.


No, there's no OOP in the OP :stickout: (j/k)

I do see your point, and I think there's a fine line between cheating (ie, attempting to solve the problem without exerting your own effort) and using a resource (ie, attempting to learn more on your own).

Yeah, most courses I've taken provided you with plenty of resources to complete an assignment. I can certainly remember others (mostly calculus, for some reason) where the course materials were unclear, professor was largely unavailable, and there was an insurmountable language barrier between myself and the T.A.

I also get the impression that a lot of the questions that we see in these forums are now coming from High School classes as well. It's great that there are programming courses at that level of education now, but I can only assume that the overall level of instruction and resources isn't as good as you'd find in a post-secondary academic setting.

Either way, the most instructive classes I've ever had are the ones in which the teacher approached the material with the attitude, "I'm going to teach you HOW to learn about/research X for yourself" rather than "I'm going to teach you X." That's really what school is about--learning how to learn.

mattle
08-26-2009, 06:21 AM
if there is no solution provided to me

Case in point....that would be what I'd call the attitude of a cheater. Regardless of what you hear the politicians say, get used to not having all of life's answers "provided to you," or get ready for disappointment. :)

andyxfun
08-26-2009, 08:15 AM
look man,i have no attitude of a cheater,ok??
this whole stuff about the website contest is optional,not some kind of homework and i just make this website to learn ok??i don't gain or lose anything!i don't cheat because there is nothing to cheat at!and if you put it that way,at school,i'm the student type that offers the resolved math questions not the one that asks for them and not only at math but at many disciplines,ok?? after all i just came here to ask for help and the whole discussion went offtopic talking about me cheating or not and things like that...

and now to settle this: i surfed the web,searching for answers,scanned my php scripts,found many errors,repaired them(missing files,missplaced files, scripting errors...) and now it's all about this last bit of script which just won't work: the email arrives but with the contents of the template file:


what is wrong with the next php file:


<?php

$htm = file_get_contents('template.htm');
$search = array('%message%','%name%','%subject%','%email%');
$replace = array("some text","my name","some boring subject","another plain boring email address");
str_replace($search, $replace, $htm);

echo $htm;

?>


i have the template.htm,the contents.htm and the save.php in the same foder and after the script ends,the result is iddentical to the template.htm with no changes

i got this bit of code right from this forum from another topic,copied and adapted it but it won't work,i tried to search explanations on the net about each function but everything seems ok,can you figure it out?

and thanks for the help til now!:):):)


ps:i forgot to add this: the contents.htm file is chmoded to 777

so any sollution?

mattle
08-26-2009, 09:05 AM
Your problem is in str_replace(). Check the manual for proper usage (hint: what is the function's return value?).

As for the whole "cheating" debate--when you come to us with pasted code and ask for "solutions" instead of help, you lose credibility when you argue that you are trying to learn...

petteyg359
08-26-2009, 09:50 AM
in save.php

function java_redirect(){

echo '<script type="text/javascript">'."\n";
echo '<!--'."\n";
echo 'setTimeout("Redirect()",3000)'."\n";
echo 'function Redirect()'."\n";
echo '{'."\n";
echo 'location.href = "contact.htm"'."\n";
echo '}'."\n";
echo '// -->'."\n";
echo '</script>'."\n";

}


why this line
echo '<!--'."\n";
and
echo '// -->'."\n";

remove that and try
actually those will result html comment and nothing displayed in the page

hope it helps you
Rasin

That prevents crappy browsers that don't understand the <script> tag from trying to interpret the Javascript as HTML. It is considered good practice on any page that might be viewed by users with older crappy browsers.

andyxfun
08-26-2009, 10:31 AM
thanks very very very much!
it's all ok now,apparently,and yes,i have understood what was wrong.
about the cheating thing: i don't have what to cheat at,i just wanted that website done nicely and used the info i got from the internet as well as i could.that was above my level of knowledge in php but i wanted to make things work so i used it.
thanks again and keep up the good work,i simply love this forum!:>
thanks a million times!:>

abdicar
08-30-2009, 10:08 PM
great to see this fixed... may in the next theard i'll help u :D