Hi there everyone,
I'm trying to build a classifieds system that uses the phpBB3 session system and after hours of trying to set session data, I just found that phpBB3 won't store any session variables that aren't pre-approved via their session table.
For future upgrades and such, I try not to modify the phpBB3 core code, so I'm left looking for alternate methods of storing some data to allow the user a chance to make changes to their data without losing anything else they submitted.
Here's an example of what I was trying to do before I realized I wasn't allowed to set $_SESSION data:
case "1" :
$query = "SELECT * FROM `classifieds_categories` ORDER BY `parent`,`title` ASC;";
$result = mysql_query($query);
$parents = array();
$categories = array();
while ($row = mysql_fetch_assoc($result)) {
if ($row['parent'] == 0) {
$parents[$row['id']] = $row['title'];
} else {
$categories[$row['id']] = $parents[$row['parent']]."~>".$row['title'];
}// end if
}
echo("<form method='post' name='choosing_category' action='classifieds.php?action=ad_create&step=2'>
<h2>Select a category for your advertisement:</h2>
<select name='adcreate_cat_id' id='adcreate_cat_id'>");
foreach ($categories as $id => $title) {
echo '<option value="'.$id.'">'.$title.'</option>'."\n";
}
echo("</select><br />
<br />
<INPUT TYPE='image' SRC='images/icons/green-check-mark.jpg' BORDER='0' VALUE='Submit'>
</form>
");
break;
case "2" :
if(!ISSET($_POST['adcreate_cat_id']) AND !ISSET($_SESSION['adcreate_cat_id'])){
echo("<br />
<br />
<font color='red'><b>Oopsie:</b></font> You have not selected a category.<br>
<br />
No biggie. Just <a href='classifieds.php?action=ad_create&step=1' alt='select a category'>click here to choose one</a>.");
}else{
if(ISSET($_POST['adcreate_cat_id'])){
$_SESSION['adcreate_cat_id'] = $_POST['adcreate_cat_id'];
}
if(ISSET($_SESSION['adcreate_title'])){
$adcreate_title = $_SESSION['adcreate_title'];
}else{
$adcreate_title = '';
}
echo("
<h2>Create a Title</h2>
<p>A few things to remember to make your title as useful as possible:</p>
<ol>
<li><b>Don't include 'For Sale', 'FS', 'Wanted', 'W' or similar</b> The classifieds have been designed to make it obvious, so including this will only deduct from your allowed number of characters.</li><br />
<li><b>Don't use 'Look at me!' tags like 'Cheap!', '****' or the like</b> Use your title to provide a descriptive summary of your advertisement. Titles that do not meet this requirement will either cause the ad to be deactivated and flagged for alteration or deleted, depending totally on how grumpy I am that day.</li><br />
<li><b>Plain text only</b> The title does not support html, bbcode or images.</li>
</ol>
<form method='post' name='choosing_title' action='classifieds.php?action=ad_create&step=3'>
<table>
<tr>
<td align='left'>
<b>Title:</b>
</td>
<td align='left'>
<input type='text' size='40' maxlength='40' name='adcreate_title' value='".$adcreate_title."'>
</td>
</tr>
</table>
<INPUT TYPE='image' SRC='images/icons/green-check-mark.jpg' BORDER='0' VALUE='Submit'>
</form>");
}
break;
case "3" :
if(!ISSET($_SESSION['adcreate_cat_id'])){
echo("<br />
<br />
<font color='red'><b>Oopsie:</b></font> You have not selected a category.<br>
<br />
No biggie. Just <a href='classifieds.php?action=ad_create&step=1' alt='select a category'>click here to choose one</a>.");
}else{
if(!ISSET($_POST['adcreate_title']) AND !ISSET($_SESSION['adcreate_title'])){
echo("<br />
<br />
<font color='red'><b>Oopsie:</b></font> You have not created a title.<br>
<br />
No biggie. Just <a href='classifieds.php?action=ad_create&step=2' alt='create a title'>click here to create one</a>.");
}else{
echo("<h2>Create your advertisement body</h2>
<form method='post' name='choosing_body' action='classifieds.php?action=ad_create&step=4'>
<textarea name='adcreate_body' cols=60 rows=10 maxlength='500'>");
if(ISSET($_SESSION['adcreate_body'])){
if($_SESSION['adcreate_body'] != ''){
echo $_SESSION['adcreate_body'];
}
}
echo("</textarea><br />
<br />
<INPUT TYPE='image' SRC='images/icons/green-check-mark.jpg' BORDER='0' VALUE='Submit'>
</form>");
}
}
break;
case "4" :
if(!ISSET($_SESSION['adcreate_cat_id'])){
echo("<br />
<br />
<font color='red'><b>Oopsie:</b></font> You have not selected a category.<br>
<br />
No biggie. Just <a href='classifieds.php?action=ad_create&step=1' alt='select a category'>click here to choose one</a>.");
}else{
if(!ISSET($_SESSION['adcreate_title'])){
echo("<br />
<br />
<font color='red'><b>Oopsie:</b></font> You have not created a title.<br>
<br />
No biggie. Just <a href='classifieds.php?action=ad_create&step=2' alt='create a title'>click here to create one</a>.");
}else{
if(!ISSET($_POST['adcreate_body']) AND !ISSET($_SESSION['adcreate_body'])){
echo("<br />
<br />
<font color='red'><b>Oopsie:</b></font> You have not created a body.<br>
<br />
No biggie. Just <a href='classifieds.php?action=ad_create&step=3' alt='create a title'>click here to create one</a>.");
}else{
echo("images go here");
}
}
}
break;
The two methods I've thought of resolving this issue are cookies or storing the info in the DB Neither seem nearly as handy but I was wondering if anyone had any input on what they think would be the best method to get around this before I invest any more time on it.