News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Integrating the SMF user system with my tutorial system! Help please.

Started by drcrazy, April 26, 2006, 12:24:41 PM

Previous topic - Next topic

drcrazy

I am expecting that lots of people here have an idea about SMF site integration that is why I asked. Sorry if I have the wrong forum. Here is my script:
<?
require("forum/SSI.php");
require_once('forum/Sources/QueryString.php');
require_once('forum/Sources/Subs.php');
require_once('forum/Sources/Errors.php');
require_once('forum/Sources/Load.php');
require_once('forum/Sources/Security.php');
if ($context['user']['is_guest'])
{
echo "You must be a member to submit a tutorial!";
}
else {
if ($_POST[submit]) {

$author= $_POST['author'];
$title = $_POST['title'];
$category = $_POST['category'];
$content = $_POST['content'];
$type = "unapproved";

if($tutorial==NULL|$category==NULL|$content==NULL) {
echo '<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tablebg">
  <tr>
    <td height="27" id="topic">Error</td>
  </tr>
  <tr>
    <td id="cellbg">A field was left blank! Please go back and fix this problem </td>
  </tr>
  <tr>
    <td height="10" bgcolor="#7bd100"></td>
  </tr>
</table>';
}
if(!$tutorial==NULL|$category==NULL|$content==NULL)
{
$query = mysql_query("INSERT INTO tutorials (author, category, type, content, title) VALUES('$author','$category','$type','$content','$title')");
echo '<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tablebg">
  <tr>
    <td height="27" id="topic">Submitted Succesfully!</td>
  </tr>
  <tr>
    <td id="cellbg">Your tutorial will soon be approved by an admin. Please wait up to 24 hours. You can check the progress on all your tutorials on the \'My Tutorials\' page. </td>
  </tr>
  <tr>
    <td height="10" bgcolor="#7bd100"></td>
  </tr>
</table>';
}
}
else {
echo '<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tablebg">
  <tr>
    <td height="27" id="topic">Submit Tutorial </td>
  </tr>
  <tr>
    <td id="cellbg"><form name="form1" method="post" action="">
      Tutorial:
          <input name="title" type="text" class="fields" id="title">
          <p>
      Category:
      <select name="category" id="category">
        <option value="asp" selected>Actionscript Pro</option>
        <option value="blender">Blender 3D</option>
        <option value="gametips">Game Tips</option>
        <option value="dreamweaver">Dreamweaver</option>
        <option value="fireworks">Fireworks</option>
        <option value="frontpage">Frontpage</option>
        <option value="gimp">Gimp</option>
        <option value="javascript">Javascript</option>
        <option value="paint">Paint</option>
        <option value="psp">Paint Shop Pro</option>
        <option value="photoshop">Photoshop</option>
        <option value="php">PHP</option>
        <option value="rpgtoolkit">RPG Toolkit</option>
      </select>
      <p>
      Content:<br>
      <textarea name="content" cols="70" rows="20" class="fields" id="content"></textarea>
<p>
<input name="submit" type="submit" id="submit" value="Submit">

    </form></td>
  </tr>
  <tr>
    <td height="10" bgcolor="#7bd100"></td>
  </tr>
</table>';
}
}
?>

I want it so that instead of $_POST['author']; it is the SMF user variable and if the user is not logged in then it displays the 'Only members can submit tutorials' notice. Help would be greatly appreciated.

Leipe Po


<?php

// for the username:
$author $context['user']['username'];


// if else for the uservalidation:

if(!$context['user']['is_logged']) {
echo 
'Please make sure you are logged in!!!';
} else {

// stuff here

}
?>

There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

drcrazy

thanks for trying to help but you login on the forums but when you go to the site it always says 'You have to login to submit tutorials. It is really doing my head in a bit. Here is my code now but it still doesn't work:
<?
require("forum/SSI.php");
require_once('forum/Sources/QueryString.php');
require_once('forum/Sources/Subs.php');
require_once('forum/Sources/Errors.php');
require_once('forum/Sources/Load.php');
require_once('forum/Sources/Security.php');
if ($_POST[submit]) {

$author= $context['user']['username'];
$title = $_POST['title'];
$category = $_POST['category'];
$content = $_POST['content'];
$type = "unapproved";

if($tutorial==NULL|$category==NULL|$content==NULL) {
echo '<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tablebg">
  <tr>
    <td height="27" id="topic">Error</td>
  </tr>
  <tr>
    <td id="cellbg">A field was left blank! Please go back and fix this problem </td>
  </tr>
  <tr>
    <td height="10" bgcolor="#7bd100"></td>
  </tr>
</table>';
}
if(!$tutorial==NULL|$category==NULL|$content==NULL)
{
$query = mysql_query("INSERT INTO tutorials (author, category, type, content, title) VALUES('$author','$category','$type','$content','$title')");
echo '<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tablebg">
  <tr>
    <td height="27" id="topic">Submitted Succesfully!</td>
  </tr>
  <tr>
    <td id="cellbg">Your tutorial will soon be approved by an admin. Please wait up to 24 hours. You can check the progress on all your tutorials on the \'My Tutorials\' page. </td>
  </tr>
  <tr>
    <td height="10" bgcolor="#7bd100"></td>
  </tr>
</table>';
}
}
if(!$context['user']['is_logged']) {
{
echo "You must be a member to submit a tutorial!";
}
if ($context['user']['is_logged']) {

if (!$_POST[submit]) {
echo '<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tablebg">
  <tr>
    <td height="27" id="topic">Submit Tutorial </td>
  </tr>
  <tr>
    <td id="cellbg"><form name="form1" method="post" action="">
      Tutorial:
          <input name="title" type="text" class="fields" id="title">
          <p>
      Category:
      <select name="category" id="category">
        <option value="asp" selected>Actionscript Pro</option>
        <option value="blender">Blender 3D</option>
        <option value="gametips">Game Tips</option>
        <option value="dreamweaver">Dreamweaver</option>
        <option value="fireworks">Fireworks</option>
        <option value="frontpage">Frontpage</option>
        <option value="gimp">Gimp</option>
        <option value="javascript">Javascript</option>
        <option value="paint">Paint</option>
        <option value="psp">Paint Shop Pro</option>
        <option value="photoshop">Photoshop</option>
        <option value="php">PHP</option>
        <option value="rpgtoolkit">RPG Toolkit</option>
      </select>
      <p>
      Content:<br>
      <textarea name="content" cols="70" rows="20" class="fields" id="content"></textarea>
<p>
<input name="submit" type="submit" id="submit" value="Submit">

    </form></td>
  </tr>
  <tr>
    <td height="10" bgcolor="#7bd100"></td>
  </tr>
</table>';
}
}
}
?>


Dannii

You don't need all your require_once lines, just include SSI.php.

$_POST[submit] should be changed to $_POST['submit']

$author= $context['user']['username'];
$title = $_POST['title'];
$category = $_POST['category'];
$content = $_POST['content'];
$type = "unapproved";
You need to verify these better to stop SQL injection.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

drcrazy

it still doesn't help the fact that it can't tell if the user is logged in or not. Thanks for clearing that bit up anyway. I will try and remember to use the ''s in future.

Advertisement: