My ISP finally got php installed, but it is not working proper. Or I am doing something wrong...,I think it is is them.
I found a a couple "free" servers that offer php and the scripts work fine on those systems.
I am not a programmer and know very little about what to look for. JAVA and cgi are a struggle...but I always manage...but this has me stumped...as well as the admin at VCN.
The posting action does not work.
If someone has the time and inclination to help could you please look at : http://www.cnw.vcn.com/hello.php (info)
and http://www.cnw.vcn.com/action.php (post action test)
and http://www.cnw.vcn.com/gb/index.php (a guestbook)
perhaps push me in the right direction?
Thanks.
kmj
06-18-2001, 09:11 AM
Perhaps if you were to post your code, we might be able to help more? Are others using that ISP able to use PHP w/o problems?
<font size="3" color="#000000" class="s4" face="Arial, Helvetica"><a href="post.htm">Post a message to this guestbook</a></font>
<?php
if (file_exists("messages.txt")):
include("messages.txt");
endif;
?>
<br><br>
<font size="3" color="#000000" class="s4" face="Arial, Helvetica"><a href="post.htm">Post a message to this guestbook</a></font>
</font>
</BODY>
</HTML>
(guestbook.php):
ript language="php">
/*
This script was originally created by Daniel Williams daniel@webdrive.co.nz
This version has been modified by Mark Donchek (webmaster@markdonline.com)to include the following functionality:
- A checkbox for the users' choice in format (HTML or No HTML).
- The ability for a user to preview their changes before submitting.
- A check box for a user to decide whether or not to see a preview.
- Blank submissions are blocked from submission.
- An error message has been added when trying to insert a blank submission into the submit page.
- The primary submit form has been separated from guestbook.php3 in order to help prevent against multiple submissions (more aesthetic than practical).
- Various aesthetic changes (for consistency with www.markdonline.com's (http://www.markdonline.com's) look and feel,
including a single pixel gif (black.gif) in place of the HTML line rule.
if (($name == "") AND ($email == "") AND ($comments == "")):
$error1 = "<font size='3' class='s4' color='red' face='Arial, Helvetica'><STRONG>It appears as if you've tried to submit a blank form:</STRONG></font><br>";
<P><font size='3' class='s4' face='Arial, Helvetica'>Confirm your comment and submit, or <a href='index.php3'>view the guestbook</a> without making an entry</FONT></P>
<P>
<font size='3' class='s4' face='Arial, Helvetica'>Add a message to my guest book:</FONT>
<BR>
<TEXTAREA NAME=comments ROWS=10 COLS=30 WRAP=virtual>$comments</TEXTAREA>
<BR><BR>
Check here if you used HTML tags in any field: <INPUT TYPE=checkbox NAME=html value='1'");if ($html == 1):$xbox = CHECKED; echo $xbox; else:'';endif;echo("><BR>
</FONT>
</P>
<P><font size='2' class='s3' face='Arial, Helvetica'><INPUT TYPE=submit NAME=gb VALUE='Add Message'> Please press only once: this may take a moment (or two).</FONT>
</FORM></P>
</BODY>
</HTML>
");
else:
$gbFile = "messages.txt"; // Location of link database file
$gbPage = "index.php3"; // Link page file
if ($html == 1):
$allowHTML = 1; // To allow HTML in site description 1 = Yes, 0 = No
else:
$allowHTML = 0; // To allow HTML in site description 1 = Yes, 0 = No
endif;
$notify = 0; // Would you like to be notified when a link is added? 1 = yes, 0 = No
$my_email = "you@youremailaddress.com"; // Enter your email address
$subject = "New Guestbook Entry" ; // Enter the subject of the notification email
//endif from very top where checking if form is empty
endif;
</script>
and the post action test:
<html><head><title>PHP Test</title></head>
<body>
<form action="action.php" method="post">
Your name: <input type="text" name="name">
You age: <input type="text" name="age">
<input type="submit">
</form>
</body></html>
Sweede
06-18-2001, 10:40 AM
First off, i dont know if you coded all that or not, but using
if():
else if:
endif;
is OUTDATED and WRONG, it is depreceated and will not be supported in future versions. in fact, the PHP devs and manual have suggested that one discontinue that usage since php v3 began.
The <Script language=php> tag is ok, sort of, it certiantly is NOT needed here. using <?php would work just the same.
this is also a waste
$var = "hello;
echo $var;
assuming that $var is used(echoed) NO where else, this is a waste of memory space. on a small app it might not be no big deal, but larger apps with hundreds or thousands of variables like this, you'll waste megs of memory on code.
When escaping large blocks of HTML (such as the section after } else if ($form == preview) { ), escape it from php (i.e. use a php end tag ?>, and if you need to use a variable <html code><?php echo $var ?></html code>
this entire line itself is definitly a huge coding error
Check here if you used HTML tags in any field: <INPUT TYPE=checkbox NAME=html value='1'");if ($html == 1):$xbox = CHECKED; echo $xbox; else:'';endif;echo("><BR>
1. the if() statement uses the old outdated, wrong syntax.
2. its inline, in the middle of an HTML tag
3. its all on one line, which is VERY VERY wrong.
4. again its $var ="foo"; echo var;
you have a lot of un-needed variables and waste.
there is also a section that is exactly like another function called htmlspecialchars(), and using/allowing HTML is a bad idea anyways, specially in this case.
fopen("$gbFile","w"); is incorrect, it should be
fopen($gbFile,"w");
you've had mis-named variables allllllllllllllllllllllllll over the place, many of them where never set anywhere.
countlass others.
your guestbook.php
<?php
/*
This script was originally created by Daniel Williams daniel@webdrive.co.nz
This version has been modified by Mark Donchek (webmaster@markdonline.com)to include the following functionality:
- A checkbox for the users' choice in format (HTML or No HTML).
- The ability for a user to preview their changes before submitting.
- A check box for a user to decide whether or not to see a preview.
- Blank submissions are blocked from submission.
- An error message has been added when trying to insert a blank submission into the submit page.
- The primary submit form has been separated from guestbook.php3 in order to help prevent against multiple submissions (more aesthetic than practical).
- Various aesthetic changes (for consistency with www.markdonline.com's (http://www.markdonline.com's) look and feel,
including a single pixel gif (black.gif) in place of the HTML line rule.
*/
if ( !isset($gbsubmit) ) {
?>
<html>
<head>
<title>Untitled</title>
</head>
<style type='text/css'>
<!--//
.s5 {font-size: 20px; font-family: arial,helvetica}
.s4 {font-size: 18px; font-family: arial,helvetica}
.s3 {font-size: 13px; font-family: arial,helvetica; letter-spacing: 1px}
//-->
</style>
<BODY>
<p><font face="Arial, Helvetica" size="3" class="s4">Confirm your comment and submit, or <a href="index.php3">view the guestbook</a> without making an entry</font></p>
<p><font size='3' class='s4' face='Arial, Helvetica'>Add a message to my guest book:</font></P>
<form action="<?php echo $PHP_SELF ?>" method="post">
<font face="Arial, Helvetica" size="3" class="s4">
Name:<br><input type="text" name="name" size="30" maxlength="80"><br>
Email:<br><input type="text" name="email" size="30" maxlength="80"><br>
Notes:<br>
<textarea cols="30" rows="10" name="comments"></textarea>
<br><br>
</font>
</p>
<P><font face="Arial, Helvetica" size="2" class="s3"><input type="submit" name="gbsubmit" value="Add Message"> Please press only once: this may take a moment (or two).</font>
</form></p>
</body>
</html>
<?php
} else {
if ( ($name == "") AND ($email == "") AND ($comments == "") ) {
echo "<font size='3' class='s4' color='red' face='Arial, Helvetica'><strong>It appears as if you've tried to submit a blank form:</strong></font><br>";
} else {
$gbFile = "messages.txt"; // Location of link database file
$notify = 0; // Would you like to be notified when a link is added? 1 = yes, 0 = No
$my_email = "you@youremailaddress.com"; // Enter your email address
$subject = "New Guestbook Entry" ; // Enter the subject of the notification email
if ( $notify == 1 ) {
$comments = ereg_replace("<br>","\n",$comments);
mail ( $my_email, "Example Issues List Entry","Name : $name\nEmail : $email\nNote:\n$comments\n", "From: $email\n" );
}
include($gbFile);
}
}
?>
your index.php
<html>
<head>
<title>Untitled</title>
</head>
<body>
<font size="3" color="#000000" class="s4" face="Arial, Helvetica"><a href="guestbook.php">Post a message to this guestbook</a></font>
<?php
if ( file_exists("messages.txt") ) {
include("messages.txt");
}
?>
<br><br>
<font size="3" color="#000000" class="s4" face="Arial, Helvetica"><a href="guestbook.php">Post a message to this guestbook</a></font>
</font>
</body>
</html>
you dont need 4 seperate files to do this..
the index.php page is piddly, the guestbook.php does all you need, and the messages.txt file holds the data.
this current code has no consistancy or redundancy checking, and probably should be given up for a better one.
now that the code is FAR better, your problem was this...
in your guestbook.php page, you have..
if (($name == "") AND ($email == "") AND ($comments == "")):
but then in your post.htm
Your name: <input type="text" name="name">
You age: <input type="text" name="age">
<input type="submit">
the only var you have that matches the if statement is the $name.
perhaps changing your form to match the variables you check ??
or use mine up there.
justlinux.com
Copyright Internet.com Inc. All Rights Reserved.