Jump to content

jordan443

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by jordan443

  1. 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);
    }
    ?>
    
  2. 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??

     

  3. 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?

  4.  

    When I tried it I got the following result, which appears to be correct:

    <form id="theform" method="POST" action="/description.php">
    <input type="hidden" name="manga" value="value"/>
    </form>
    
    <style>table{margin:0 0 10px 0}table.chp{margin:0!important;width:100%}tr,td{padding:0;margin:0}table.chp td.c1{}table.chp td.c2{width:85px}table.chp td.c3{width:40px}table.chp td.c4{width:75px}a.cvr{display:block;width:36px;height:36px;overflow:hidden}</style>
    <div class="wpm_pag mng_lts_chp">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/medaka-box/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/215;medaka-box_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/medaka-box/" style="font-size:14px"><b>Medaka Box</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/medaka-box/192/">Chapter 192 - END</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/1730;kingdom_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/" style="font-size:14px"><b>Kingdom</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/85/">Chapter 85 - Kyoukai's Dance</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/84/">Chapter 84 - Assassin's Strike</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/83/">Chapter 83 - Shiyuu</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/82/">Chapter 82 - Hundred-Man Commander</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/81/">Chapter 81 - Farewell</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kingdom/80/">Chapter 80 - Separation</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kodomo-no-jikan/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/544;kodomo-no-jikan_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kodomo-no-jikan/" style="font-size:14px"><b>Kodomo no Jikan</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kodomo-no-jikan/93/">Chapter 93 - END</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kissxsis/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/464;kissxsis_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kissxsis/" style="font-size:14px"><b>KissxSis</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/kissxsis/71/">Chapter 71 - Secret Affection</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/last-inning/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/804;last-inning_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/last-inning/" style="font-size:14px"><b>Last Inning</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/last-inning/152/">Chapter 152 - A Sudden Turn</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/watashi-ni-xx-shinasai/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/440;watashi-ni-xx-shinasai_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/watashi-ni-xx-shinasai/" style="font-size:14px"><b>Watashi ni xx Shinasai!</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/watashi-ni-xx-shinasai/47/">Chapter 47 - Feelings Within The Pin</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/dogs-bullets-carnage/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/dogs-bullets-carnage_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/dogs-bullets-carnage/" style="font-size:14px"><b>Dogs: Bullets & Carnage</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/dogs-bullets-carnage/82/">Chapter 82 - Chapter 82</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/dogs-bullets-carnage/81/">Chapter 81 - Chapter 81</a></td>
    <td class="c2">Today</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/dogs-bullets-carnage/80/">Chapter 80 - Chapter 80</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/hungry-joker/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/hungry_1_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/hungry-joker/" style="font-size:14px"><b>Hungry Joker</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/hungry-joker/21/">Chapter 21 - Human vs. God</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/haikyu/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/haikyu_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/haikyu/" style="font-size:14px"><b>Haikyu!!</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/haikyu/58/">Chapter 58 - Chapter 58</a></td>
    <td class="c2">Today</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/shinobi-no-kuni/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/shinobi-no-kuni_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/shinobi-no-kuni/" style="font-size:14px"><b>Shinobi no Kuni</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/shinobi-no-kuni/20/">Chapter 20 - Chapter 20</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/city-of-dead-sorcerer/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/city-of-dead-sorcerer_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/city-of-dead-sorcerer/" style="font-size:14px"><b>City of Dead Sorcerer</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/city-of-dead-sorcerer/46/">Chapter 46 - Chapter 46</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/assassination-classroom/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/assassination-classroom_2_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <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>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/assassination-classroom/40/">Chapter 40 - Nomination Time.</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/i-dont-want-this-kind-of-hero/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/i-dont-want-this-kind-of-hero_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/i-dont-want-this-kind-of-hero/" style="font-size:14px"><b>I Don't Want This Kind of Hero</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/i-dont-want-this-kind-of-hero/9/">Chapter 9 - Chapter 9</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/celestial-clothes/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/celestial-clothes_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/celestial-clothes/" style="font-size:14px"><b>Celestial Clothes</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/celestial-clothes/6/">Chapter 6 - Fate and Wish</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/celestial-clothes/5/">Chapter 5 - Breaking the evil</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/nichijou/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/nichijou_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/nichijou/" style="font-size:14px"><b>Nichijou</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/nichijou/69/">Chapter 69 - Chapter 69</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
    <td width="40px">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/again/">
    <img src="http://eyemanga.com/wp-content/manga/cover/tbn/again_1_36x0.jpg"/>
    </a>
    </td>
    <td>
    <table class="chp">
    <tr>
    <td colspan="4">
    <a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/again/" style="font-size:14px"><b>Again!!</b></a>
    </td>
    </tr>
    <tr>
    <td class="c1"><a onclick="document.forms.theform.manga.value='http://eyemanga.com/again/34/';document.forms.theform.submit();return false" href="http://eyemanga.com/again/34/">Chapter 34 - Chapter 34</a></td>
    <td class="c2">Apr 24, 2013</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <hr style="border:dashed #BEBEBE; border-width:1px 0 0; height:0;">
    <table width="1
    

    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>

  5. Perhaps if you posted at least some of the code it would be easier for others to help you figure out how to change it.

    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

  6.  

    Try something like this instead:

    $file_contents = file_get_contents('http://eyemanga.com');
    preg_match_all('/<a class="cvr" href="([^"]+)"/', $file_contents, $matches);
    
    foreach ($matches[1] as $link)
    	echo '<a href="'.$link.'">'.$link.'</a>';
    

    I tried what you suggested and I'm not sure how to apply it to my current code?

  7. 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?

  8. 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?

  9. 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"]."',
     
    )");
  10. 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.