Jump to content

ittech

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ittech's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [quote author=Jenk link=topic=104600.msg417453#msg417453 date=1155827567] [code]<?php if ($session->userid == $user_id_from_post) {   // show buttons } ?>[/code] to get you started. [/quote] that's great someone helpped me. But how come when i login the echo goes and when i log out it shows? It should be the other way around? Any ideas?
  2. My point to the post was to find out a way for my script to let the person who submitted the post delete it or edit it by adding in a button after it has check the post belongs to that user (am not sure how to check the post to the user). But you have helped more then those at codingforum thanks a lot. still confused.com  ???
  3. i use a mysql database  ;) please help me out codingforums can't seem to help me so am hoping there are professionals on this help forum  ;D [code]<? include("include/session.php"); ?> <html> <title>simple</title> <body> <table> <tr><td> <? if($session->logged_in){    echo "<h1>Logged In</h1>";    echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"        ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"        ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";    if($session->isAdmin()){       echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";    }    echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <h1>Login</h1> <? if($form->num_errors > 0){    echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp; <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> <? } echo "</td></tr><tr><td align=\"center\"><br><br>"; echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>"; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.<br><br>"; include("include/view_active.php"); ?> </td></tr> </table> </body> </html> <? include("include/dbcon.php"); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row  ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection  } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="./create_topic.php"><strong>Create New Topic</strong> </a></td> </tr> </table> [/code] VIEW_TOPIC.php [code]<? include("include/session.php"); ?> <h1>User: <? echo $session->username; ?></h1> <?php $host="localhost";  $username="****";    $password="****";  $db_name="****";    $tbl_name="****";  mysql_connect("$host", "$username", "$password")or die("cannot connect");  mysql_select_db("$db_name")or die("cannot select DB"); $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#F8F7F1"><strong><? echo $rows['topic']; ?></strong></td> </tr> <tr> <td bgcolor="#F8F7F1"><? echo $rows['detail']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>By :</strong> <? echo $rows['name']; ?> <strong>Email : </strong><? echo $rows['email'];?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Date/time : </strong><? echo $rows['datetime']; ?></td> </tr> </table></td> </tr> </table> <BR> <?php $tbl_name2="forum_answer"; // Switch to table "forum_answer"  $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'"; $result2=mysql_query($sql2); while($rows=mysql_fetch_array($result2)){ ?> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#F8F7F1"><strong>ID</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_id']; ?></td> </tr> <tr> <td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td> <td width="5%" bgcolor="#F8F7F1">:</td> <td width="77%" bgcolor="#F8F7F1"><? echo $rows['a_name']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Email</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_email']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Answer</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_answer']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Date/Time</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_datetime']; ?></td> </tr> </table></td> </tr> </table><br> <? } $sql3="SELECT view FROM $tbl_name WHERE id='$id'"; $result3=mysql_query($sql3); $rows=mysql_fetch_array($result3); $view=$rows['view']; // if have no counter value set counter = 1 if(empty($view)){ $view=1; $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'"; $result4=mysql_query($sql4); } // count more value $addview=$view+1; $sql5="update $tbl_name set view='$addview' WHERE id='$id'"; $result5=mysql_query($sql5); mysql_close(); ?> <BR> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="add_answer.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="18%"><strong>Name</strong></td> <td width="3%">:</td> <td width="79%"><input name="a_name" type="text" id="a_name" size="45"></td> </tr> <tr> <td><strong>Email</strong></td> <td>:</td> <td><input name="a_email" type="text" id="a_email" size="45"></td> </tr> <tr> <td valign="top"><strong>Answer</strong></td> <td valign="top">:</td> <td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td> </tr> <tr> <td>&nbsp;</td> <td><input name="id" type="hidden" value="<? echo $id; ?>"></td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </td> </form> </tr> </table> [/code]
  4. yes thats what i want to do but i don't know how to code that? ??? my script logs there userid when they post and only lets members see the submit post box. Am 5 weeks old to php and most the stuff i have done i learned from phpfreaks. thanks for the reply i hope you reply back to this  ;D
  5. Hi, i made a member system got some of it from phpfreaks and it works great  ;D but i want to make a posting area for my members. i seen the simple forum script of here so i got some thing like that in mind. I just don't know how to allow my members to edit or delete a post. i know how to delete posts and edit them if you know what i mean it's just allowing the person who submits the post to edit or delete it?????? it would be really great if someone could show me as well as tell me how this could be done. Thanks
×
×
  • 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.