Jump to content

Problem passing data from php to mySql database - help!


Recommended Posts

I need help trying to figure out why my pulldown menu is not behaving correctly. Currently it appears, and you can select the 'rating' you want to give to a selected post and submit. However the value selected does not save to/pass on to the database  :( I've attached the snippet of code - everything to this point is working fine. I don't know why this isn't working. I've gone over it again and again and it should work i think... Help :'(

 

Also, I'm a newb so am i describing this correctly? Is this data a 'value' or a 'variable' ?

 

<tr>

	<td valign="top" align="right"><p><b>RATING:</b></p></td>
	<td>
		<SELECT name="RATING">
		<?php
		$i=0;
		FOREACH ($boardRating as $thisLevel) {
		echo "<option value='$i'";
		if ($record["rating"] == $i) { echo " selected"; }
		echo ">$thisLevel</option>\n";
		$i++;
		} // end FOREACH
		?></select>
	</td>

</tr>

I presume that you are submitting this via a form, and that you are using POST as your transport method.

 

On the page that you submit to you can use: $_POST['RATING'] (or $_GET['RATING'] if using the get method) to retrieve the posted variable. You can also use something like:

 

<?php

echo '<pre>';
print_r($_POST); // Or $_GET
echo '</pre>';

?>

 

To view all of your post data that is being submitted to your processing script.

 

Hope this helps you debug the issue.

 

Paul

Hello Paul,
 I don't understand what your saying. I'm not using any forms (I did a search for 'forms' to make sure of this. I almost never use forms - i use text areas. Forms just confuse me  :'(  Base on what your saying, should i write my php to be as so?


	<td valign="top" align="right"><p><b>RATING:</b></p></td>
	<td>
		<SELECT name="RATING">
		<?php
		$i=0;
		FOREACH ($boardRating as $thisLevel) {
		echo "<option value='$i'";
		if ($record["rating"] == $i) { echo " selected"; }
		echo '<pre>';
                       print_r($_POST); // Or $_GET
                       echo '</pre>';
		?></select>
	</td>

When I do this I get the following error 'Parse error: parse error, unexpected $ in /home/content/z/a/n/zanland/html/xpg/messages/post1.php on line 854'
		?></select>


Yes? No?



?>

 

What does this mean?

However the value selected does not save to/pass on to the database

 

Hi Neil.Johnson,

  When I write that 'the value selected does not save to/pass on to the database' I mean that if select a rating from the pulldown menu, the value selected (lets say 2 or 4 stars), the value stays selected, and when you click submit, everything appears to submit and everything is good. But if you look in the database, the information (2 of 4 stars) is not there. If you go back to the page you were on via the 'edit' tool, the pulldown is clear (no stars). So the data, the value (2 of 4 stars) has defaulted to zero/no stars once more :(

 

Any help is appreciated

Thanks

In order to submit any user input (e.g. textarea / select / input) you need to wrap your fields in a form. Below is a basic example which should allow you to see what is going on - the page simple submits to itself for now, but should get you going:

 

<?php

$options = array(
1 => 'Bad', 
2 => 'Poor', 
3 => 'Average', 
4 => 'Good', 
5 => 'Excellent' 
);

if(isset($_POST['rateme']))
{
echo 'You clicked save! and chose '.$options[$_POST['rating']].'<br /><br />';

echo 'The posted data looks like this:</br />';
echo '<pre>';
	print_r($_POST);
echo '</pre>';
}

?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<select name="rating">
<?php
foreach($options as $key => $value)
{
	echo '<option value="'.$key.'"';
		if((isset($_POST['rating']) AND $_POST['rating'] == $key) OR (!isset($_POST['rating']) AND $key == 3))
		{ 
			echo ' selected="selected"';
		}
	echo '>'.$value.'</option>';
}
?>
</select>

<input type="submit" name="rateme" value="Save" />

</form>

Weird Blinky101,

  I did not know this -- and I have lots of pull downs, i have three different pull downs on the page i'm working on and the other two are working fine and they don't use forms (at least I don't think they do.)

 

I've included the full code below so you can peak and see - no forms (at least I don't think i'm using any forms - I'm a newb so i kind of piece and patch junk together and i so so so readily admit that i don't know the first thing about anything ;)

 

 

<?php
$restricted="login";
$notifyTest = array();

include ("../functions.php");

$timeoptions=array("Pre-dawn", "Early Morning", "Morning", "Midday", "Early Afternoon", "Afternoon", "Early Evening", "Evening", "Late Night");

approveVars(array("submit", "id", "thread", "continuedfrom", "deletethread"));

$post=array();
$errorText="";

$fields = array("subject", "content", "charid", "summary", "previously", "rating", "thread", "thread2", "action", "notification", "ooc", "featuring", "tags", "timeofday", "location", "oocbox", "gamedate", "userid", "continuedfrom", "storyteller", "approved");
$patterns = array ("/([^\n\r\f])[\n\r\f]+([^\n\r\f])/");
$replace = array ("\\1\n\\2");

FOREACH ($fields as $thisField) {
$post[$thisField] = "";
$THISFIELD = strtoupper($thisField);

if (isset($_POST[$THISFIELD])) { ${$THISFIELD} = trim($_POST[$THISFIELD]);

${$THISFIELD} = preg_replace ($patterns, $replace, ${$THISFIELD});
${$THISFIELD} = preg_replace ("/\\'/", "'", ${$THISFIELD});

if ($THISFIELD == "CONTENT") { ${$THISFIELD} = preg_replace("/<+([Tt]ag[^<>\n]+)>+/","[$1]",${$THISFIELD}); }

if ($THISFIELD != "CONTENT" && $THISFIELD != "SUMMARY" && $THISFIELD != "PREVIOUSLY" && $THISFIELD != "OOC") {
$patterns2 = array ("/<+[^<>\n]+>+/");
$replace2 = array ("");
${$THISFIELD} = preg_replace($patterns2,$replace2,${$THISFIELD});
} // end if stripping tags from non-blob areas.

$older = ${$THISFIELD}; ${$THISFIELD} = preg_replace("/<+[^<>][^<>][^<>]+>+/","",$older);
$older = ${$THISFIELD}; ${$THISFIELD} = preg_replace("/<+\/*[ou]*l[i]*>+/","", $older);

if ($older != ${$THISFIELD}) { $errorText = "You may only use simple HTML tags such as <b>, <i>, <u>, etc, and only in the "Message", "Previously", "Summary" and "OOC" fields. Longer tags have been stripped out of your post. Please check the message and resubmit.\n\n<!-- $older -->\n<!-- " . ${$THISFIELD} . " -->"; }

} else { ${$THISFIELD} = ""; }

} // end foreach

if (!$thread && $THREAD) { $thread=$THREAD; }

// DEFAULT DATE WRANGLING

// THE DEFAULT DATE SHOULD BE September 16, 2004
// the real date for that is Sunday, February 13, 2005

// to get the default date: CURRENT NUMBER OF DAYS

$gamedateFile = "$basefile/gamedate/gamedate.txt";
$tempy = file($gamedateFile);
$gameDate = trim($tempy[0]);
$realDate = trim($tempy[1]);

$sql  = "DATE_FORMAT(NOW(),'%Y%m%d%H%i%s') as currentTime, FROM_DAYS(TO_DAYS('$gameDate') + FLOOR((TO_DAYS(NOW()) - TO_DAYS('$realDate')) /14)) as defaultdate, (TO_DAYS(NOW()) - TO_DAYS('$realDate'))/14 - FLOOR((TO_DAYS(NOW()) - TO_DAYS('$realDate'))/14) as gameremainder";

if (!$id && $thread) {
$sql = "SELECT subject, charid, storyteller, featuring, rating, timeofday, gamedate, location, summary, thread, notification," . $sql  . " FROM board WHERE thread=$thread AND approved!='' ORDER BY dateadded DESC LIMIT 1";
} else if ($id) {
$sql = "SELECT *, " . $sql  . " FROM board WHERE id=$id";
} else {
$sql = "SELECT " . $sql;
} // end if ID and THREAD

// echo "<!-- SQL: $sql -->\n";

$result=mysql_query($sql);
$post = mysql_fetch_assoc($result); 

if (isset($post["thread"])) {
if ($post["thread"]) { $locked=threadLocked($post["thread"]); }
} // end if thread to check for locked-ness

$patterns = array ("/<\/*p>/","/[\r\f\n]+/");
$replace = array ("\n","\n\n");
$post = preg_replace($patterns,$replace,$post);
$currentTime = $post["currentTime"];
$defaultdate = $post["defaultdate"];

$post["defaulttime"] = floor($post["gameremainder"] * 9);

$defaulttime = $timeoptions[$post["defaulttime"]];

// echo "<!-- Game Remainder: $post[gameremainder] -->\n";
// echo "<!-- Default Time: $post[defaulttime] -->\n";
// echo "<!-- Default Time: $defaulttime -->\n";

FOREACH ($fields as $thisField) {
if (isset($post[$thisField])) { ${$thisField} = trim($post[$thisField]); } else { ${$thisField} = "";

// echo "<!-- Line 82 \$thread? $thread -->\n";

if ($thisField != "content" && $thisField != "summary" && $thisField != "previously" && $thisField != "ooc") {
${$thisField} = htmlspecialchars(${$thisField});
} // end if swapping quotes

} // end if set

} // end foreach

if ($submit && ($OOCBOX == "true" || (!$CHARID && !$STORYTELLER))) {
if (!$OOC && $CONTENT) { $OOC = $CONTENT; }
$CONTENT = "";
$CHARID = "";
$TIMEOFDAY = $timeofday;
} // end

if (!$continuedfrom && isset($_REQUEST["continuedfrom"])) { $continuedfrom = $_REQUEST["continuedfrom"]; }

if ($STORYTELLER) {
$CHARID="";
} // end if storyteller

// IF THEY'VE SUBMITTED A POST...

if ($submit) {

echo "<!-- Already approved? " . $post["approved"] . " -->\n";
echo "<!-- APPROVING? " . $APPROVED . " -->\n";
// die;

if ($ACTION == "approved" AND !$post["approved"]) { $modDate = "NOW()"; } else { $modDate = "dateadded"; }

if (!$GAMEDATE) { $GAMEDATE = $defaultdate; }

//realtime - 56 days = gametime;
// NOW() - 732006 / 14 - 56 = Gametime.

if (!$OOCBOX && !$STORYTELLER) {
$CODENAME = getChar($CHARID);
if (!$FEATURING) { $FEATURING = $CODENAME;
} else if (!preg_match("/$CODENAME/", $FEATURING)) { $FEATURING .= ", $CODENAME"; }
} // end if they didn't include themselves in "featuring"

if ($CONTINUEDFROM) {
$continueTest = readDatabase("SELECT thread FROM board WHERE id=$CONTINUEDFROM LIMIT 1");
if ($continueTest["thread"] == $THREAD) { $CONTINUEDFROM=""; }
} // end if continued from

$FEATURING = preg_replace("/, *,/",",",$FEATURING);
$FEATURING = preg_replace("/^,/","",$FEATURING);
$FEATURING = preg_replace("/,$/","",$FEATURING);

if ($THREAD2 && $THREAD2 != $THREAD) { $THREAD = $THREAD2; }

if (!$id) {
$sql = "INSERT INTO board (userid,
charid,
storyteller,
subject,
previously,
rating,
content,
summary,
dateadded, lastmodified,
ooc,
featuring,
tags,
timeofday,
location,
thread,
gamedate,
continuedfrom,
notification,
approved) VALUES (\"$login\",
\"$CHARID\",
\"$STORYTELLER\",
\"$SUBJECT\",
\"$PREVIOUSLY\",
\"$RATING\",
\"$CONTENT\",
\"$SUMMARY\",
NOW(),
NOW(),
\"$OOC\",
\"$FEATURING\",
\"$TAGS\",
\"$TIMEOFDAY\",
\"$LOCATION\",
\"$THREAD\",
\"$GAMEDATE\",
\"$CONTINUEDFROM\",
\"$NOTIFICATION\",
\"$ACTION\")";
} else {
if (!$THREAD) { $THREAD = $id; }
$sql = "UPDATE board SET charid=\"$CHARID\", 
storyteller=\"$STORYTELLER\",
thread=\"$THREAD\", 
subject=\"$SUBJECT\",
previously=\"$PREVIOUSLY\",
rating=\"$RATING\",
summary=\"$SUMMARY\", 
content=\"$CONTENT\",
ooc=\"$OOC\",
featuring=\"$FEATURING\",
tags=\"$TAGS\",
timeofday=\"$TIMEOFDAY\", 
location=\"$LOCATION\",
gamedate=\"$GAMEDATE\",
continuedfrom=\"$CONTINUEDFROM\", 
notification=\"$NOTIFICATION\", 
approved=\"$ACTION\",
dateadded=$modDate WHERE id=$id";
} // end if ID

if (!$SUBJECT) { $errorText="You have not entered a Subject line for this message. Please submit the form again after making changes."; }

// echo "<!-- CONTINUEDFROM: $CONTINUEDFROM -->\n";

if ($CONTINUEDFROM) {
if (threadLocked($CONTINUEDFROM)) { $errorText= "You cannot branch off from that thread, because it is locked."; }
} // end if CONTINUEDFROM

if (!$OOCBOX) {
if (!$CONTENT) { $errorText = "You cannot submit an empty message. Please submit the form again after making changes."; }
if ($CHARID=='---') { $errorText = "You must choose a main character from the list. Please submit the form again after making changes."; }
if (!$FEATURING && $CHARID) { $errorText = "You must specify the characters this post features. Please submit the form again after making changes."; }
} else {
if (!$OOC) { $errorText = "You cannot submit an empty message. Please submit the form again after making changes."; }
} // end if not OOC-only

if ($ACTION == "delete") { $sql = "DELETE from board WHERE id=$id"; $errorText=""; $jumpto="/messages.php"; }
if ($ACTION == "deletethread") { $sql = "DELETE from board WHERE thread=$id OR id=$id"; $errorText=""; $jumpto="/messages.php"; }

if (!$errorText) {

if ($id) {
if ($ACTION=="locked") { $lockThread = mysql_query("UPDATE board set approved='locked' WHERE id=$THREAD LIMIT 1"); $ACTION = "approved"; }
// echo "<!-- LOCKED:  UPDATE board set approved='locked' WHERE id=$THREAD LIMIT 1  -->\n";
if ($ACTION=="approved") { $lockThread = mysql_query("UPDATE board set approved='approved' WHERE id=$THREAD LIMIT 1"); $ACTION = "approved"; }
// echo "<!-- UNLOCKED:  UPDATE board set approved='approved' WHERE id=$THREAD LIMIT 1 -->\n";
} // end if id

$result = mysql_query($sql);

if (mysql_errno()) { errorPage("MYSQL Error #" . mysql_errno() . " when updating Cerebra: <b>" . mysql_error() . "</b>. Please check with the system administrator and inform her/him of the error.<br><br><span class='fineprint'>$sql</span>"); die; }

$notifyThis='';
if (!$id) { $notifyThis='true'; $id = mysql_insert_id(); }
if (!$THREAD) { $sql = "UPDATE board SET thread=$id WHERE id=\"$id\""; $result2 = mysql_query($sql); $THREAD=$id; }

if ($notifyThis) { notify($THREAD); }

if ($ACTION != "delete" && $ACTION != "deletethread") { $jumpto = "/messages/display.php?id=$id"; }

header ("Location: $jumpto");
die;

} // end if no error text

} // end if SUBMITTED

echo "<!-- Main SQL: $sql -->\n\n";

echo "<!-- ID: $id -->\n";
echo "<!-- Thread: $thread -->\n";
echo "<!-- Login: $login -->\n";

if ($errorText) {
FOREACH ($fields as $thisField) {
$THISFIELD = strtoupper($thisField);
if ((!preg_match("/which character/",$errorText) && $thisField=="charid") || $thisField != "charid" ) { ${$thisField} = ${$THISFIELD}; }
} // end foreach
} // end if error text

FOREACH ($fields as $thisField) {
if ($thisField != "content" && $thisField != "summary" && $thisField != "previously" && $thisField != "ooc") {
${$thisField} = preg_replace("/\"/",""",${$thisField});
} // end if swapping quotes
} // end foreach

// IF THEY HAVEN'T SUBMITTED, SHOW 'EM THE FORM!

echo "<!-- 190 - Thread: $thread -->\n\n";

$bodyScript = "onLoad = \"setButtonText()\"";
include ("../header.php");
// include ("/Library/WebServer/Documents/sphpell/spellcheckpageinc.php");

echo "<!-- 195 - Thread: $thread -->\n\n";
?>

<SCRIPT language="javascript">

function makeOOC(force) {

if (force=='force') { window.document.postMessage.OOCBOX.checked = true; }

if (window.document.postMessage.OOCBOX.checked == true) {
if (!window.document.postMessage.OOC.value && window.document.postMessage.CONTENT.value != '== DISABLED ==') { window.document.postMessage.OOC.value = window.document.postMessage.CONTENT.value; }

window.document.postMessage.CHARID.disabled = true;
window.document.postMessage.RATING.disabled = true;
window.document.postMessage.FEATURING.readonly = true;
window.document.postMessage.TIMEOFDAY.disabled = true;
window.document.postMessage.GAMEDATE.readonly = true;
window.document.postMessage.LOCATION.readonly = true;
window.document.postMessage.CONTENT.readonly = true;

window.document.postMessage.CONTENT.value = "== DISABLED ==";

window.document.postMessage.CONTENT.style.color = String ('#333333');

window.document.postMessage.CONTENT.style.background = String ('#888888');
window.document.postMessage.FEATURING.style.background = String ('#888888');
window.document.postMessage.LOCATION.style.background = String ('#888888');
window.document.postMessage.GAMEDATE.style.background = String ('#888888');

window.document.postMessage.OOC.focus();
} else { 
window.document.postMessage.CHARID.disabled = false;
window.document.postMessage.FEATURING.readonly = false;
window.document.postMessage.TIMEOFDAY.disabled = false;
window.document.postMessage.GAMEDATE.readonly = false;
window.document.postMessage.LOCATION.readonly = false;
window.document.postMessage.CONTENT.readonly = false;

window.document.postMessage.CONTENT.value = window.document.postMessage.OOC.value;

window.document.postMessage.OOC.value = "";

window.document.postMessage.CONTENT.style.color = String ('#000000');

window.document.postMessage.CONTENT.style.background = String ('#FFFFFF');
window.document.postMessage.FEATURING.style.background = String ('#FFFFFF');
window.document.postMessage.LOCATION.style.background = String ('#FFFFFF');
window.document.postMessage.GAMEDATE.style.background = String ('#FFFFFF');

window.document.postMessage.CONTENT.focus();
}

}

function postWarning() {

var postCheck = false;

<?php

if (!$id) {

$threadCheck = mysql_query("SELECT thread from board WHERE userid=$login AND UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 2 HOUR)) <= UNIX_TIMESTAMP(dateadded) GROUP BY thread");

// it's within a day and within 2 hours.

WHILE ($checker = mysql_fetch_assoc($threadCheck)) {
echo "if (window.document.postMessage.THREAD.value == " . $checker["thread"] . ") {\n";
echo "postCheck = true;\n";
echo "}\n";
} // end WHILE

} // end if ID
?>

if (postCheck==true) {
window.document.postMessage.submit.value = 'Submit ANYWAY';
alert("You have posted to the selected thread within the past four hours. Only submit this new post if you're sure you've given tagged players time to respond.");
window.document.getElementById('threadCheck').innerHTML="<font color='red'>You have posted to this thread in the last four hours.</font>";
} else {
window.document.postMessage.submit.value = 'Submit';
window.document.getElementById('threadCheck').innerHTML="Click to continue...";
}

}


function setButtonText() {
if (window.document.postMessage.action3.checked == true) { window.document.postMessage.submit.value = 'DELETE Post';
} else if (window.document.postMessage.action4.checked == true) { window.document.postMessage.submit.value = 'DELETE ENTIRE THREAD';
  } else { window.document.postMessage.submit.value = '<?php
if ($id) { $buttonText = "Edit Post"; } else { $buttonText = "Add Post"; }
echo $buttonText; ?>';
}

}

</SCRIPT>


<SCRIPT language="javascript">
//  Live Word Count Script - added May 2nd -->


function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
      if (wordcounter > 9999) {field.value = field.value.substring(0, x);}
      else {countfield.value = maxlimit - wordcounter;}
      }
   }

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
      {field.value = field.value.substring(0, maxlimit);}
      else
      {countfield.value = maxlimit - field.value.length;}
  }
//  End -->
</script>


<table border="0" cellpadding="6" cellspacing="0" width="95%">
<form name="postMessage" action="/messages/post.php" method="post" enctype="multipart/form-data">
<tr><td colspan="2">
<center>
<h1><font color="#A5B9D5">

<?php					
if (!$id) { echo "Post New Message"; } else { echo "Edit Message"; }
?>

</font></h1>
<p>Please allow at least 2 hours for tagged players to respond to your posts before posting to the same thread again. 

<?php
if ($thread) { echo "<a href=\"javascript:openimage('thread.php?hideHeaders=true&thread=$thread',400,500,1)\"
>Review this thread in a new window.</a>"; }

echo "</p></center>\n";

if ($errorText) { echo "<p><font color='red'>$errorText</font> <a href='/messages.php'>Click here to cancel and return to the Messages area.</a></p>\n"; }					
?>
</td>
</tr>


<tr>
<td colspan="2" valign="middle" height="20" align="center">
<hr color="#050F1D" size="5">
</td>
</tr>

<tr>
<td align="right"><p><b>POST AS:</b></p></td>
<td>

<?php
if (!$moderator && $storyteller) {
echo "<p>$storyteller<input type='hidden' name='STORYTELLER' value=\"" . htmlspecialchars($storyteller) . "\"></p>";
} else {

echo "<select name=\"CHARID\">\n";

echo "<option value=''> -- Select character -- </option>\n";

if (!$id) { $charid = 0; }

echo "<!-- 243 - Thread: $thread -->\n\n";
$selecty = false;

$sql = "SELECT id,codename,name,player from cerebra WHERE player=$login AND approved='true' ORDER BY codename";
$charResult = mysql_query($sql);

echo "\n\n<!-- FIND CHARS: $sql -->\n\n";

$usedCharacters = array() ;

if (mysql_num_rows($charResult)) {

echo "<optgroup label='My Characters'>\n";

WHILE ($character = mysql_fetch_assoc($charResult)) {
echo "<option value='" . $character["id"] . "'";

if ($character["id"] == $charid || (!$charid && $pref["primarychar"] == $character["id"] && !$storyteller)) { echo " selected"; $selecty = true; }

$usedCharacters[] = $character["id"];
echo ">";

echo strtoupper($character["codename"]);
if ($character["name"]) { echo " (" . $character["name"] . ")"; }
echo "</option>\n";
} // end WHILE

echo "</optgroup>\n";
} // end if any characters to post as


// recently used characters

$char_criteria="";
if (count($usedCharacters)) { $char_criteria = "AND (charid !=" . implode(") AND (charid!=", $usedCharacters) . ")"; }

$sql = "SELECT charid, cerebra.id, codename, cerebra.name FROM board LEFT JOIN cerebra ON cerebra.id = charid WHERE TO_DAYS(NOW()) - TO_DAYS(dateadded) < 14 AND charid > 0 $char_criteria AND board.userid=$login GROUP BY charid ORDER BY codename";
$charResult = mysql_query($sql);

if (mysql_num_rows($charResult)) {

echo "<optgroup label='Recent Characters'>\n";

WHILE ($character = mysql_fetch_assoc($charResult)) {

if (!in_array($character["id"], $usedCharacters)) {

echo "<option value='" . $character["id"] . "'";

if ($character["id"] == $charid || (!$charid && $pref["primarychar"] == $character["id"] && !$storyteller)) { echo " selected"; $selecty = true; }

echo ">";

echo strtoupper($character["codename"]);
if ($character["name"]) { echo " (" . $character["name"] . ")"; }
echo "</option>\n";
} // end if not already placed
} // end WHILE

echo "</optgroup>\n";
} // end if any characters to post as


$sql = "SELECT id,npc,codename,name,player from cerebra WHERE (npc=$login OR npc='general' OR npc='modonly') AND approved='true' ORDER BY codename";
$charResult = mysql_query($sql);

echo "\n\n<!-- FIND NPCs: $sql -->\n\n";

if (mysql_num_rows($charResult)) {

echo "<optgroup label='NPCs'>\n";

WHILE ($character = mysql_fetch_assoc($charResult)) {
if ($character["npc"] != "modonly" || $moderator) {
echo "<option value='" . $character["id"] . "'";
if ($character["id"] == $charid) { echo " selected"; $selecty=true; }
echo ">";

echo strtoupper($character["codename"]);
if ($character["name"]) { echo " (" . $character["name"] . ")"; }
echo "</option>\n";
} // end if modonly
} // end WHILE

echo "</optgroup>\n";

} // end if num rows

echo "<!-- 365 - Thread: $thread -->\n\n";

if ($moderator) { 
echo "<optgroup label='PCs'>\n";

$sql = "SELECT id,codename,name,player from cerebra WHERE approved='true' AND npc = '' OR npc IS NULL ORDER BY codename";
$charResult = mysql_query($sql);

WHILE ($character = mysql_fetch_assoc($charResult)) {
echo "<option value='" . $character["id"] . "'";

if ($character["id"] == $charid) { echo " selected"; $selecty=true; }

echo ">";

echo strtoupper($character["codename"]);
if ($character["name"]) { echo " (" . $character["name"] . ")"; }
echo "</option>\n";
} // end WHILE

echo "</optgroup>\n";

} // end if moderator

if (!$selecty && $charid) {

echo "<optgroup label='Current Selection'>\n";
echo "<option value='$charid' selected>" . strtoupper(htmlspecialchars(getChar($charid)));
if (getRealName($charid) != "(Unrevealed)") { echo " (" . htmlspecialchars(getRealName($charid)) . ")"; }
echo "</option>\n";
echo "</optgroup>\n";

} // end if not already listed

echo "</select>";

} // end if not moderator and it's a storyteller post

echo "</td></tr>\n\n";



if ($moderator) {

?><tr>
<td valign="top" align="right"><p><b>...or, enter here:</b><br>
<span class='fineprint'>specify character posting here if not found in above pulldown.</span></p></td>
<td valign="top"><input type="text" name="STORYTELLER" size="80" value="<?php
if  ($id) { echo $storyteller; } ?>"></td>
</tr>

<?php
} // end if moderator

?>

<tr>
<td valign="top" align="right"><p><b>THREAD:</b></p></td>
<td valign="top"><select name="THREAD" onChange="postWarning();">
<option value="">-- New Thread --</option>

<?php
$currDate = "";

echo "<!-- 407 - Thread: $thread -->\n\n";

$sql = "SELECT id,thread,subject,DATE_FORMAT(MAX(dateadded), \"%c/%e/%y\") as dateformat, MAX(dateadded) as dateaddedm, MAX(approved) as locked from board GROUP BY thread HAVING locked <> \"locked\" ORDER BY dateaddedm DESC LIMIT 50";
$threadResult = mysql_query($sql);
$threadArray = array();

echo "\n\n<!-- THREAD: $THREAD -->\n";
echo "\n\n<!-- thread: $thread -->\n";

echo "\n\n<!-- FIND THREADS: $sql -->\n\n";

$alreadyDone = "";
WHILE ($threadArray = mysql_fetch_assoc($threadResult)) {
if ($threadArray["dateformat"] != $currDate) {
$currDate = $threadArray["dateformat"];
if ($currDate) { echo "</optgroup>\n"; }
echo "<optgroup label='$currDate'>";
} // end if not the same date

echo "<option value=\"" . $threadArray["thread"] . "\"";
if ($threadArray["thread"] == $thread) { echo " selected"; $alreadyDone = "true"; }
echo ">";
$newText = shortenText(getThreadName($threadArray["thread"]),32);
if ($newText != getThreadName($threadArray["thread"])) { $newText = $newText . "&#8230;"; }
echo "$newText</option>\n";
} // end WHILE

if (mysql_errno()) { echo mysql_errno().": (THREAD) error: " . mysql_error(); }


if ($thread && !$alreadyDone ) {

$sql = "SELECT id,thread,subject,DATE_FORMAT(MAX(dateadded), \"%c/%e/%y\") as dateformat, MAX(dateadded) as dateaddedm from board WHERE thread=$thread GROUP BY thread";

$threadResult = mysql_query($sql);
WHILE ($threadArray = mysql_fetch_assoc($threadResult)) {
$currDate = $threadArray["dateformat"];
echo "<optgroup label='$currDate'>";
echo "<option value='$thread' SELECTED>";
$newText = shortenText(getThreadName($thread),32);
if ($newText != getThreadName($thread)) { $newText = $newText . "&#8230;"; }
echo $newText . "</option>\n";
} // end WHILE
} // end if thread
?>
</select>

		<?php
		if ($moderator) { echo "<br><p>Manual thread entry: <input name='THREAD2' value='$thread'></p>"; }
		?>
	</td>

</tr>
<tr>

	<td valign="top" align="right"><p><b>RATING:</b></p></td>
	<td>
		<SELECT name="RATING">
		<?php
		$i=0;
		FOREACH ($boardRating as $thisLevel) {
		echo "<option value='$i'";
		if ($record["rating"] == $i) { echo " selected"; }
		echo ">$thisLevel</option>\n";
		$i++;
		} // end FOREACH
		?></select>
	</td>

</tr>
<tr>

	<td valign="top" align="right"><p><b>SUBJECT:</b></p></td>
	<td valign="top"><input type="text" name="SUBJECT" size="80" value="<?php echo $subject; ?>"></td>

</tr>
<tr>

	<td align="right" valign="top"><p><b>OOC?</b></p></td>
	<td><p><input type="checkbox" value="true" id="OOCBOX" name="OOCBOX" onClick="makeOOC()"><label for="OOCBOX" name="OOCBoxlabel"> OOC-only post. Some fields will be disabled.</label></p></td>

</tr>
<tr>

	<td align="right" valign="top"><p><b>FEATURING:</b><br>
	<span class='fineprint'>Codenames of characters in this post.</span></p></td>
	<td valign="top"><input type="text" name="FEATURING" size="80" value="<?php echo $featuring; ?>"></td>
</tr>
<tr>
<td align="right" valign="top"><p><b>TIME OF DAY:</b></p></td>
<td valign="top"><select name="TIMEOFDAY">

<?php
echo "<!-- Time of Day: '$timeofday' -->\n";
FOREACH ($timeoptions as $thisone) {
echo "<option value='$thisone'";
if ($thisone == $timeofday || (!$timeofday && $thisone == $defaulttime)) { echo " selected"; }
echo ">$thisone</option>\n";
} // end FOREACH
?>
</select></td>
</tr>

<tr>
<td align="right" valign="top"><p><b>GAME DATE:</b><br>
<span class='fineprint'><i>YYYY-MM-DD</i></span></p></td>
<td valign="top"><input type="text" name="GAMEDATE" size="12" value="<?php
if ($gamedate) { echo $gamedate; } else { echo $defaultdate; } ?>"></td>
</tr>

<tr>
<td align="right" valign="top"><p><b>LOCATION:</b></p></td>
<td valign="top"><input type="text" name="LOCATION" size="80" value="<?php echo $location; ?>"></td>
</tr>

<tr><td colspan="2"><hr color="#050F1D" size="5"></td></tr>

<tr>
<td valign="top" align="right"><p><b>Continued from...</b><br>
<span class='fineprint'>If this message continues from a message in another thread, enter its unique id number here. Check that it's the right one by clicking "Check".</p></td>
<td valign="top"><p><nobr>#<INPUT name="CONTINUEDFROM" size=25 value="<?php echo $continuedfrom; ?>"> <input type="submit" name="linkCheck" value="Check" onclick="javascript: if (window.document.postMessage.CONTINUEDFROM.value > 0) { openimage('/messages/display.php?hideHeaders=true&id=' + window.document.postMessage.CONTINUEDFROM.value,400,500,true); } return false;"></nobr></p></td>
</tr>

<tr>
<td align="right" valign="top"><p><b>PREVIOUSILY:</b></p></td>
<td><textarea name=PREVIOUSLY rows=3 cols=80 wrap=virtual><?php

if (!$id && $thread) { echo $summary; } else { echo $previously; } ?></textarea></td>
</tr>


<tr>
<td align="right" valign="top">
<p><b>MESSAGE:</b><br>
<span class='fineprint'>Before posting, please read and spellcheck your post first. If you mention someone please add them to your tags.</span>
<td><textarea name=CONTENT rows=22 cols=80 wrap=virtual 
onKeyDown="wordCounter(this.form.Q3367,this.form.remLen,200);" 
onKeyUp="wordCounter(this.form.CONTENT,this.form.remLen,200);">
<?php echo $content;
?></textarea>
<br><span class='fineprint'>Words remaining: 
<input type='text' readonly name='remLen' size='5' value='200'></span><br>
<INPUT TYPE="reset" VALUE="Reset" id=reset1 name=reset1></td></tr>
</textarea></td>
</tr>

<tr>
<td align="right" valign="top"><p><b>SUMMARY:</b></p></td>
<td><textarea name=SUMMARY rows=3 cols=80 wrap=virtual>
<?php
if ($id) { echo $summary; } 
?>
</textarea></td>
</tr>

<tr><td colspan="2"><hr color="#050F1D" size="5"></td></tr>

<tr>
<td align="right" valign="top"><p><b>OOC:</b></p></td>
<td><textarea name=OOC rows=6 cols=80 wrap=virtual style="color:000000"><?php echo stripslashes($ooc); ?></textarea></td>
</tr>

<tr>
<td align="right" valign="top"><p><b>TAGS:</b></p></td>
<td><input type="text" name="TAGS" size="82" value="<?php echo $tags; ?>"></td>
</tr>

<tr><td colspan="2"><hr color="#050F1D" size="5"></td></tr>

<tr>
<td align="right" valign="top"><a name='status'></a>
<p><b>Options:</b></p></td>
<td><p>

<?php
if ($moderator && $id) {
echo "<!-- APPROVED? $approved -->\n";
echo "<input type='radio' value='' id='action0' name='ACTION' onClick='setButtonText()'";
if ($approved == "") { echo " checked "; }
echo "><label for='action0' name='action0label'> Not Approved</label><br>\n";

echo "<input type='radio' name='ACTION' name='action1' value='approved'";
if (!$deletethread && $approved == "approved") { echo " checked "; }
echo "id='action1' onClick='setButtonText()'><label for='action1'> Approved for posting</label><br>\n";

echo "<input type='radio' value='locked' id='action2' name='ACTION' onClick='setButtonText()'";
if ($locked && !$deletethread) { echo " checked"; }
echo "><label for='action2'> Lock Thread</label><br>\n";

echo "<input type='radio' value='delete' id='action3' name='ACTION' onClick='setButtonText()'><label for='action3'> REMOVE MESSAGE</label><br>\n";

echo "<input type='radio' value='deletethread' id='action4' name='ACTION' onClick='setButtonText()'";
if ($deletethread) { echo " checked"; }
echo "><label for='action4'> <font color='red'><b>REMOVE THREAD</b></font></label><br>\n";
echo "</p>\n<p>";

} else if ($moderator) {

echo "<input type='checkbox' name='ACTION' name='action1' value='approved' checked id='action1' onClick='setButtonText()'><label for='action1'> Approved for posting</label><br>\n";
echo "</p>\n<p>";

} else if (!$moderator) {

$tempy = readDatabase("SELECT moderated from login WHERE id=$login");
if (!$tempy["moderated"] && !$id) { $approved="approved"; }
echo "<input type='hidden' name='ACTION' value='$approved'>";

} // end if moderator

echo "<input type=hidden name=id value=$id>\n"; 


$notifyTest["notification"] = "";
$notifyCheck = "";

if ($id) {
$notifySQL = "SELECT notification from board WHERE (userid=$login AND thread=$thread) OR id=$id ORDER BY dateadded DESC LIMIT 1";
echo "<!-- Notify with ID: $notifySQL -->\n";
$notifyTest = readDatabase($notifySQL);
} else if ($thread) {
$notifySQL = "SELECT notification from board WHERE (userid=$login AND thread=$thread) ORDER BY dateadded DESC LIMIT 1";
echo "<!-- Notify with thread: $notifySQL -->\n";
$notifyTest = readDatabase($notifySQL);
} // end if id

if ($notifyTest["notification"]) { $notifyCheck = " checked"; }

echo "<!-- NOTIFY SET? " . $notifyTest["notification"] . " -->\n";
?><input type="checkbox" name="NOTIFICATION" value="true"<?php echo $notifyCheck; ?> id="notifycheck"><label for="notifycheck"> Notify me when this thread is updated</label><?php
?></p></td>
</tr>

<tr>
<td align="right"><p><span id="threadCheck" class="fineprint">Click to post.</span></td>
<td><p><input type=submit name=submit value="<?php echo $buttonText; ?>" style="background-color:#022755;color:#FFFFFF;"></form></td>
</tr>
</table>

<?php

if (($id && !$charid) || checkOOC($thread)) {
echo "<!-- WE'RE FORCING OOC FOR SOME REASON. -->\n";
echo "<!-- ID: $id      THREAD: $thread -->\n";
echo "<SCRIPT LANGUAGE=\"javascript\">\n";
if ((!$charid && !$storyteller) || checkOOC($thread)) { echo "makeOOC('force');\n"; } else { echo "postWarning();\n"; }
echo "</SCRIPT>\n\n";
} // end if thread

include("../countdownUniversal.php");
include("../footer.php"); ?>

 

 

 

 

 

Dear god that's a lot of code... I would have to assume that the <form> elements are in your header / footer include files - although I don't have time to read 800 lines of code looking for them... You could also be using a framework with the helpers included for you - again, I don't know.

 

Hopefully my previous post will have given you the most basic example possible and you can go from there.

 

Good luck!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.