Jump to content

jordan443

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by jordan443

  1. short tags work so that doesn't seem to be the problem
  2. I can't get it to create the file or write to it. However, When I manually make the file and write in it myself, it will display it in the chat box.
  3. Im trying to make an Instant Message box on my site. First, you type in a username then I want it to create a new html file in /Users/ called (username).html . than I want the chat box on the site to post to and display the text in Users/(username).html . I can't seem to get it to work this is what I have: test.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link type="text/css" rel="stylesheet" href="style.css" /> <style type="text/css">html { background-color: #264C67; }</style> </head> <body> <? session_start(); function loginForm(){ echo' <div id="loginform"> <form action="test.php" method="post"> <p>Please enter your name to continue:</p> <label for="name">Name:</label> <input type="text" name="name" id="name" /> <input type="submit" name="enter" id="enter" value="Enter" /> </form> </div> '; } if(isset($_POST['enter'])){ if($_POST['name'] != ""){ $_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name'])); } else{ echo '<span class="error">Please type in a name</span>'; } } ?> <?php if(!isset($_SESSION['name'])){ loginForm(); } else{ ?> <div id="wrapper"> <div id="menu"> <p class="welcome">Welcome, <b><?php echo $_SESSION['name']; ?></b></p> <p class="logout"><a id="exit" href="#">Exit Chat</a></p> <div style="clear:both"></div> </div> <div id="chatbox"> <div id="chatbox"><?php if(file_exists("Users/" . $_SESSION['name'] . ".html") && filesize("Users/" . $_SESSION['name'] . ".html") > 0){ $handle = fopen("Users/" . $_SESSION['name'] . ".html", "r"); $contents = fread($handle, filesize("Users/" . $_SESSION['name'] . ".html")); fclose($handle); echo $contents; } ?></div> </div> <form name="message" action=""> <input name="usermsg" type="text" id="usermsg" size="63" /> <input name="submitmsg" type="submit" id="submitmsg" value="Send" /> </form> </div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> // jQuery Document $(document).ready(function(){ //If user submits the form $("#submitmsg").click(function(){ var clientmsg = $("#usermsg").val(); $.post("posttest.php", {text: clientmsg}); $("#usermsg").attr("value", ""); return false; }); //Load the file containing the chat log function loadLog(){ var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20; $.ajax({ url: "Users/" . $_SESSION['name'] . ".html", cache: false, success: function(html){ $("#chatbox").html(html); //Insert chat log into the #chatbox div var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20; if(newscrollHeight > oldscrollHeight){ $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal'); //Autoscroll to bottom of div } }, }); } setInterval (loadLog, 1000); //Reload file every 2.5 seconds //If user wants to end session $("#exit").click(function(){ var exit = confirm("Are you sure you want to end the session?"); if(exit==true){window.location = 'test.php?logout=true';} }); }); </script> <?php if(isset($_GET['logout'])){ //Simple exit message $fp = fopen("Users/" . $_SESSION['name'] . ".html", 'a'); fwrite($fp, "<div class='msgln'><i>User ". $_SESSION['name'] ." has left the chat session.</i><br></div>"); fclose($fp); session_destroy(); header("Location: test.php"); //Redirect the user } ?> <?php } ?> </body> </html> posttest.php: <? session_start(); if(isset($_SESSION['name'])){ $text = $_POST['text']; $fp = fopen("Users/" . $_SESSION['name'] . ".html", 'a'); fwrite($fp, "<div class='msgln'>(".date("g:i A").") <b>".$_SESSION['name']."</b>: ".stripslashes(htmlspecialchars($text))."<br></div>"); fclose($fp); } ?>
  4. So I'm tried to make a script that grabs html from a page and echos a part of it. I wanted to make it start before <h1 class="ttl"> and end before <b>Tagged as</b>. Heres what I have: <?php $file_contents = file_get_contents('http://eyemanga.com/beelzebub/'); $start = strpos($file_contents, '<h1 class="ttl">'); $end = strpos($file_contents, '<b>Tagged as</b>', $start); $code = substr($file_contents, $start, $end); echo $code; ?> When I use it it starts at the right place but it doesn't end in the same place I defined. Any ideas??
  5. Lemmin, thats what I tried at first but the output of it only shows the links when I want to keep the styling and text. So is there a way to use a foreach loop with an alternative to str_replace that will replace each document.forms.theform.manga.value='(whatever)' value with the link in each href attribute?
  6. But if you click one of the links, you'll notice that it POSTs the same value for every instance of document.forms.theform.manga.value= For example: <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/assassination-classroom/" style="font-size:14px"><b>Assassination Classroom</b></a> Every manga item in the output has a value of 'http://eyemanga.com/again/34/' (or whatever the first link is) when I want the value to match the link in the href attribute. So I wanted the code above to be: <a onclick="document.forms.theform.manga.value='http://eyemanga.com/assassination-classroom/';document.forms.theform.submit();return false" href="http://eyemanga.com/assassination-classroom/" style="font-size:14px"><b>Assassination Classroom</b></a>
  7. So this is what I have put together so far: <form id="theform" method="POST" action="/description.php"> <input type="hidden" name="manga" value="value"/> </form> <?php $file_contents = file_get_contents('http://eyemanga.com'); $start = strpos($file_contents, '<style>table{margin:0 0 10px 0}'); $end = strpos($file_contents, '</tr> </table> </td> </tr> </table>', $start); $rawcode = substr($file_contents, $start, $end); $code = str_replace('<a class="cvr"', "<a", "$rawcode"); preg_match_all('/<a href="([^"]+)"/', $code, $matches); foreach ($matches[1] as $link) $codetest = str_replace('<a', '<a onclick="document.forms.theform.manga.value=\''.$link.'\';document.forms.theform.submit();return false"', "$code"); echo $codetest; ?> The problem is that now it is posting the same value for every link
  8. I tried what you suggested and I'm not sure how to apply it to my current code?
  9. Currently, I have made script that gets a lot of links from another site and puts these links into a form format, where it POSTs the value of the link to another page on my site. That works fine. The problem is that the value of every link is the same. Is there any way to make the value of the <a> tags match the text in between the <a> tags? For example: I want to make this: <a value="">One</a> <a value="">Two</a> <a value="">Purple</a> <a value="">Four</a> <a value="">Puppy</a> Be automatically changed to this: <a value="One">One</a> <a value="Two">Two</a> <a value="Purple">Purple</a> <a value="Four">Four</a> <a value="Puppy">Puppy</a> Any ideas?
  10. Sorry I'm new to PHP i don't really understand???
  11. Sorry I'm new to PHP i don't really understand???
  12. How would I automatically make the value of each (different) link the same as the text in-between the <a> tags?
  13. I'm making a manga (Japanese comic) reading site and on the front page it shows the latest feed of new manga from another site using this code: http://pastebin.com/dsQzbJRX That works fine but now I want to somehow turn each link on the page into a POST form submit button that posts the name of the manga to '/description.php' Any ideas?
  14. I'm need a script that replaces multiple <a href="example.com"> tags with <a href="example2.com" onClick='this.form.submit()'> I have already wrote the part for grabbing the html (the html grabbed is $code) ........... $code = substr($file_contents, $start, $end); echo $code; ?> Any ideas?
  15. I added in what you suggested on line 113 and changed the name of the input box to 'background'. It doesn't seem to be working. Right now I just want to get the url of the image saved to the database. Heres what I did to line 113: mysql_query(" INSERT INTO tz_members(usr,pass,email,regIP,dt,background) VALUES( '".$_POST['username']."', '".md5($pass)."', '".$_POST['email']."', '".$_SERVER['REMOTE_ADDR']."', NOW(), '".$_POST["background"]."', )");
  16. All of the background related lines in the code I posted are for temporarily setting the background using POST. I haven't done anything between the background and mySQL (I haven't linked 'background' to the mySQL database)
  17. I have a website where a user can create an account and log in to it (Made it off of a template). This part works fine but I want to add a new section to the mySQL table. I want this section to store a link submitted in an input box. I created a new section called 'background'(The purpose is for users to set their own background). All of the linking to the database is done. The form that I made to post the link is on line 370. The place I would like to echo background is around line 278 How would I apply this to my current code? index-4.php You can see it live at: jordan.comze.com
×
×
  • 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.