Jump to content


php shoutbox login


  • Please log in to reply
2 replies to this topic

#1 _*rc69_*

_*rc69_*
  • Guests

Posted 23 August 2004 - 08:54 PM

ok, i found a code for a working shout box i like... the thing is i dont want random ppl to beable to post in it with any random e-mail (some ppl could understand this)

so, what i want to do is change the forum so you have to login before you can post in the shout box, and all you have to do is enter the message
heres the code:

<?php 
$db_host = "localhost";
$db_user = "edited"; 
$db_password = "edited";
$db_name = "edited";

if($_POST['submit']) { 
    if(!$_POST['author']) { 
        echo 'Error ! : No name entered'; 
        die; 
    } 
    if(!$_POST['email']) { 
        echo 'Error ! : No email entered'; 
        die; 
    } 
    if(!$_POST['message']) { 
        echo 'Error ! : No message entered'; 
        die; 
    } 
    $message = strip_tags($_POST['message'], ''); 
    $email = strip_tags($_POST['email'], ''); 
    $author = strip_tags($_POST['author'], ''); 

    $message_length = strlen($message); 
    $author_length = strlen($author); 
    if($message_length > 200) { 
        echo "Error ! : Your message was too long, messages must be less than 200 chars"; 
        die; 
    } 
    if($author_length > 20) { 
        echo "Error ! : Your name was too long, names must be less than 20 chars"; 
        die; 
    } 

    mysql_connect($db_host,$db_user,$db_password) or die(mysql_error()); 

    mysql_select_db($db_name) or die(mysql_error()); 

    $date = date("D j h:i a"); 

    $query = "INSERT INTO shoutbox (message, author, email, date, ip) 
VALUES ('$message','$author','$email','$date','$_SERVER[REMOTE_ADDR]')"; 
    mysql_query($query); 
    mysql_close(); 

    echo "Thanks for your post<BR>"; 
    echo "<A HREF=\"index.php\">Back Home</A> or <A HREF=\"shoutbox.php\">View Shoutbox</A>"; 
 
} else { 

    mysql_connect($db_host,$db_user,$db_password) or die(mysql_error()); 

    mysql_select_db($db_name) or die(mysql_error()); 

    $query = "SELECT message, author, email, date, ip 
FROM shoutbox order by id DESC LIMIT 5"; 
    $result = mysql_query($query); 
    echo "<TABLE>"; 
    while($r=mysql_fetch_array($result))     
    { 
// To modify the appearance, edit this : 
        echo "<TR> 
            <TD><font class=shoutbox> 
Posted $r[date] by <A HREF=\"mailto:$r[email]\"> 
$r[author]</A></font></TD> 
        </TR> 
        <TR> 
            <TD><font class=shoutbox>$r[message]</font></TD> 
        </TR> 
        <TR> 
            <TD><HR></TD> 
        </TR>";       
    } 
    echo "</TABLE>"; 
?> 
    <FORM METHOD=POST ACTION="shoutbox.php"> 
    <TABLE> 
    <TR> 
        
      <TD>Username:</TD> 
        <TD><INPUT TYPE="text" NAME="author"></TD> 
    </TR> 
    <TR> 
        <TD>Email:</TD> 
        <TD><INPUT TYPE="text" NAME="email"></TD> 
    </TR> 
    <TR> 
        <TD>Message:</TD> 
        <TD><INPUT TYPE="text" NAME="message"></TD> 
    </TR> 
    <TR> 
        <TD>&nbsp;</TD> 
        <TD><INPUT TYPE="submit" name="submit" value="submit"></TD> 
    </TR> 
    </TABLE> 
    </FORM> 
<?php 
} 
?>

i can change the form to just say "message" easily... its the php login integration i need help with

i want them to be able to login using my phpbb forum database (so they dont have to register twice), is there any possibility of being able to do this? (there should be, ive seen sites that've done it)

thanks for any help

p.s. i of course got the whole script from a tutorial and just edited the db connect part (works great, just want to restrict the access)

#2 _*Jay_*

_*Jay_*
  • Guests

Posted 25 August 2004 - 05:53 PM

hey, what verson of phpbb we talking about? the login works slightly different on some versions, tell me what version and i might be able to help you out

there should be SDK's out there too for phpbb as it in open source an all, just search on their forums ;)

#3 _*rc69_*

_*rc69_*
  • Guests

Posted 25 August 2004 - 05:59 PM

modded from 2.0.8 to 2.0.10

as for the SDK'S... me=noob (i.e. know nothing) are you talking about the phpbb.com site forums??




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users