Page 1 of 1

guestbook problems

Posted: Mon Jun 10, 2002 3:26 pm
by HG
here are some problems I have on my guestbook

Notice: Undefined index: do_what in D:\webb\crookz\guestbook\sign.php on line 8

Notice: Undefined index: action in D:\webb\crookz\guestbook\sign.php on line 33
here are the lins in the code!

Code: Select all

<?php
global $nickname;
global $homepage;
include ("header.php"); 
include ("guest.config.php");


line 8-->

if ($_POST&#1111;'do_what']=="Submit") &#123;
		if ($_POST&#1111;'message']!="") &#123;
		$nickname = addslashes($_POST&#1111;'nickname']);
		$real_name = addslashes($_POST&#1111;'name']);
		$email = addslashes($_POST&#1111;'email']);
		$homepage = addslashes($_POST&#1111;'homepage']);
		$message = addslashes($_POST&#1111;'message']);


		$sql = "insert into $guest_tblname (nickname,  real_name,  email,  homepage,  message,  date_added) values ('$nickname', '$real_name', '$email', '$homepage', '$message',  NOW())";
		if ($add_message = mysql_query($sql)) &#123;
		echo "<h3>Sign Guestbook - Success</h3>";
		echo "<p>Your e-card message has been succesfully added.  Please <a href="index.php">click here</a> to view the card messages with your new entry.</p>";
		&#125; else &#123;
			echo "<h3>Sign Tommy's E-Card - ERROR</h3>";
			echo "<p>An error has occurred - mySQL said:</p>";
			echo mysql_error();
		&#125;

	&#125; else &#123;
		echo "<p><b>ERROR: Your entry was not submitted - you did not enter a message. </b> Please go back and enter a message.";
	&#125;


&#125; else &#123;


line 33-->

	 if ($_POST&#1111;'action']=="preview") &#123; 
	?>
<link rel="stylesheet" href="../css/tabel.css" type="text/css">
<link rel="stylesheet" href="../css/body.css" type="text/css">
<link rel="stylesheet" href="../css/link.css" type="text/css">

<body bgcolor="#CCCCCC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
		echo "\n\n<table cellspacing="1" cellpadding="3" border="0" width="100%" class="bkgrnd"><tr>\n<td class="postbkgrnd"><p class="heading"><b>From: </b>";
			if (($_POST&#1111;'nickname']=="") && ($_POST&#1111;'name']=="")) &#123;
				$nickname = "Anonymous";
			&#125; else &#123;
				$nickname = $_POST&#1111;'nickname'];
			&#125;
			if ($_POST&#1111;'email']!="") &#123;
				echo " <a href="mailto:".$_POST&#1111;'email']."">".$_POST&#1111;'nickname']."</a>";
			&#125; else &#123;
				echo $nickname;
			&#125;
			if ($_POST&#1111;'name']!="") &#123;
				echo " (".$_POST&#1111;'name'].")";
			&#125;
			if ($_POST&#1111;'homepage']!="") &#123;
				$good_url = strpos($_POST&#1111;'homepage'], "http://");
				if ($good_url === false) &#123;
					$homepage = "http://".$_POST&#1111;'homepage'];
				&#125; else &#123;
					$homepage = $_POST&#1111;'homepage'];
				&#125;
				echo "<br><b>Homepage:</b> <a href="".$homepage."" target="_new">$homepage</a>";
			&#125; 

			$msg_message = stripslashes(nl2br(htmlspecialchars($_POST&#1111;'message'])));

			if ($use_auto_smilies=="1") &#123;
			$msg_message = eregi_replace(":\)", "<IMG SRC="smilies/smile1.gif" WIDTH=15 HEIGHT=15 ALT=":)">", $msg_message);
			$msg_message = eregi_replace(":-\)", "<IMG SRC="smilies/smile1.gif" WIDTH=15 HEIGHT=15 ALT=":-)">", $msg_message);
			$msg_message = eregi_replace(":D", "<IMG SRC="smilies/smile2.gif" WIDTH=15 HEIGHT=15 ALT=":D">", $msg_message);
			$msg_message = eregi_replace(":-D", "<IMG SRC="smilies/smile2.gif" WIDTH=15 HEIGHT=15 ALT=":-D">", $msg_message);
			$msg_message = eregi_replace(":o", "<IMG SRC="smilies/smile3.gif" WIDTH=15 HEIGHT=15 ALT=":o">", $msg_message);
			$msg_message = eregi_replace(":-o", "<IMG SRC="smilies/smile3.gif" WIDTH=15 HEIGHT=15 ALT=":-o">", $msg_message);
			$msg_message = eregi_replace(":\(", "<IMG SRC="smilies/smile4.gif" WIDTH=15 HEIGHT=15 ALT=":(">", $msg_message);
			$msg_message = eregi_replace(":-\(", "<IMG SRC="smilies/smile4.gif" WIDTH=15 HEIGHT=15 ALT=":-(">", $msg_message);
			$msg_message = eregi_replace(";)", "<IMG SRC="smilies/smile5.gif" WIDTH=15 HEIGHT=15 ALT=";)">", $msg_message);
			$msg_message = eregi_replace(";-)", "<IMG SRC="smilies/smile5.gif" WIDTH=15 HEIGHT=15 ALT=";)">", $msg_message);
			$msg_message = eregi_replace(":p", "<IMG SRC="smilies/smile6.gif" WIDTH=15 HEIGHT=15 ALT=":p">", $msg_message);
			$msg_message = eregi_replace(":-p", "<IMG SRC="smilies/smile6.gif" WIDTH=15 HEIGHT=15 ALT=":p">", $msg_message);
			$msg_message = eregi_replace("8)", "<IMG SRC="smilies/smile7.gif" WIDTH=15 HEIGHT=15 ALT="8)">", $msg_message);
			$msg_message = eregi_replace("8-)", "<IMG SRC="smilies/smile7.gif" WIDTH=15 HEIGHT=15 ALT="8)">", $msg_message);
			$msg_message = eregi_replace(":\?", "<IMG SRC="smilies/smile8.gif" WIDTH=15 HEIGHT=22 ALT=":?">", $msg_message);
			$msg_message = eregi_replace(":-\?", "<IMG SRC="smilies/smile8.gif" WIDTH=15 HEIGHT=22 ALT=":?">", $msg_message);
			$msg_message = eregi_replace(":\^\)", "<IMG SRC="smilies/smile9.gif" WIDTH=15 HEIGHT=15 ALT=":\^\)">", $msg_message);
			&#125;
				echo "</p></td></tr><tr><td class="postheader"><p>".$msg_message."</p></td></tr></table>\n\n\n\n<br>";



	 &#125; else &#123;
	?>
<h3>give crOOkz a word..</h3>
	<table width="100%" border="0">
  <tr>
    <td>
      <p>Fill in the form below to add your message to the <b><a href="index.php">guestbook</a></b>. 
        Be SURE to read the stuff below first though!</p>
    </td>
  </tr>
</table>
<table width="100%" class="postbkgrnd">
  <tr>
				<td><p><b>HTML is not allowed </b>- it will be printed out in your message, which looks REALLY dumb.  Don't say I didn't warn you, and don't ask me to edit your message later if you didn't listen the first time. </p>
			
				</td>
		</tr>
		</table>

			
<table width="100%" border="0">
  <tr>
    <td>
      <p>Also remember that <b>all fields (except the message itself) are optional</b>. 
        If you enter an e-mail address, it will be visible to anyone visiting 
        the board. If there are any fields you do not wish to fill out (or that 
        do not apply, such as homepage), simply leave them blank.</p>
      <p>Now then... that said, get to it!</p>
	</td>
  </tr>
</table>
<p>&nbsp;</p>


	<?php

	 &#125;

	?>
	
		<form method=post action="sign.php">
		
  <table width="100">
    <tr>
			<td><b>Nickname:</b></td>
			<td><input type="text" name="nickname" value="<?= stripslashes(htmlspecialchars($nickname)) ?>" maxlength="100"></td>
		</tr>
		<tr>
			<td><b>Real Name:</b></td>
			<td><input type="text" name="name" value="<?= stripslashes(htmlspecialchars($_POST&#1111;'name'])) ?>" maxlength="100"></td>
		</tr>
		<tr>
			<td><b>E-Mail:</b></td>
			<td><input type="text" name="email" value="<?= stripslashes(htmlspecialchars($_POST&#1111;'email'])) ?>" maxlength="60"></td>
		</tr>
		<tr>
			<td><b>Homepage:</b></td>
			<td><input type="text" name="homepage" value="<?= stripslashes(htmlspecialchars($homepage)) ?>" maxlength="250"></td>
		</tr>
		<tr>
			<td><b>*Message:</b></td>
			<td><textarea name="message" rows="10" cols="20"><?= stripslashes(htmlspecialchars($_POST&#1111;'message'])) ?></textarea>
			<br>
			<?php 
			if ($_POST&#1111;'action']!="preview") &#123;
				echo "<input type="hidden" name="action" value="preview">";
				echo "<input type="submit" name="do_what" value="Preview">";
			&#125; elseif (($_POST&#1111;'action']=="preview") || ($_POST&#1111;'do_what']=="Preview Again") || ($_POST&#1111;'do_what']=="Preview+Again"))&#123;
				//if (($do_what=="Preview Again") ||  ($do_what=="Preview+Again")) &#123;
				echo "<input type="hidden" name="action" value="preview">";
				echo "<input type="submit"  name="do_what"value="Preview Again">&nbsp;";
				echo "<input type="submit"  name="do_what"value="Submit">";
				//&#125; 
			&#125;
			?>
		</td>
		</tr>
		</table>
		
		
		</form>


	<?php
&#125;	

include ("footer.php"); 

?>
don“t under stand this... hmmm ... 8O

Posted: Mon Jun 10, 2002 3:59 pm
by volka
it's because there is no post-data the first time you call this page.
To get rid of it check first if the field you're testing exists.

Code: Select all

if(isset($_POST&#1111;'do_what'])  && $_POST&#1111;'do_what']=="Submit")

okej... thx

Posted: Tue Jun 11, 2002 4:26 am
by HG
that worked out fine...

thank you ... have the same problems on line 139, 143, 151 and 154 hope I can find out this my self...

peace and thx again... HG

thx volka

Posted: Tue Jun 11, 2002 6:36 am
by HG
now everything is ok except lin 154