jnerotrix Posted December 5, 2008 Share Posted December 5, 2008 I got This Error Notice: Undefined index: action in /www/rack111.com/m/y/t/mytestsite/htdocs/youtube/index.php on line 6 in this code <title> Up Your Video Views </title> <center> <?php if($_POST['action'] == 'Submit') { $numTimes = (isset($_POST['times']) && is_numeric($_POST['times']))?$_POST['times']:10; $shorturl = $_POST['url']; $autoplay = "&autoplay=1"; $reloadtime = $_POST['reloadtime']; $setwidth = $_POST['setwidth']; $setheight = $_POST['setheight']; $shorturl = $_POST['url']; $fullurl = "http://www.youtube.com/watch?v=$shorturl"; function check_if_valid($fullurl) { $res = (($check = @fopen($fullurl, ‘r’)) === false) ? false : @fclose($check); return ($res == TRUE) ? VIDEO_IS_VALID:VIDEO_IS_INVALID ; } echo '<meta http-equiv="refresh" content="$reloadtime">'; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$shorturl&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$shorturl&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="$setwidth" height="$setheight"></embed></object>'; } } ?> <table border="1"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <tr> <td>Video Url:<input type="text" readonly="1" value="http://www.youtube.com/watch?v="><input type="Text" name="url"></td> </tr> <tr> <td>(Number)<input type="text" name="times" value="10"> of Times to Display Video in <input type="text" name="reloadtime" value="5">(Seconds)</td> </tr> <tr> <td>Set Width <input type="text" name="setwidth" value="425"> Set Height <input type="text" name="setheight" value="344"> </tr> <tr> <td align="center" valign="center"><input type="submit" name="action" value="Submit"></td> </tr> </form </table> Link to comment Share on other sites More sharing options...
Vince889 Posted December 5, 2008 Share Posted December 5, 2008 I really hope you don't think that actually <I>increases</i> YouTube video views. I do believe they increase their view-counts by unique IPs. Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 no it works ive done it before Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 anoby know what the problem is? Link to comment Share on other sites More sharing options...
The Little Guy Posted December 5, 2008 Share Posted December 5, 2008 <?php if(!isset($_POST['action'])){ $_POST['action'] = ''; } if($_POST['action'] == 'Submit') { $numTimes = (isset($_POST['times']) && is_numeric($_POST['times']))?$_POST['times']:10; $shorturl = $_POST['url']; $autoplay = "&autoplay=1"; $reloadtime = $_POST['reloadtime']; $setwidth = $_POST['setwidth']; $setheight = $_POST['setheight']; $shorturl = $_POST['url']; $fullurl = "http://www.youtube.com/watch?v=$shorturl"; function check_if_valid($fullurl) { $res = (($check = @fopen($fullurl, ‘r’)) === false) ? false : @fclose($check); return ($res == TRUE) ? VIDEO_IS_VALID:VIDEO_IS_INVALID ; } echo '<meta http-equiv="refresh" content="$reloadtime">'; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$shorturl&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$shorturl&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="$setwidth" height="$setheight"></embed></object>'; } } ?> <table border="1"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <tr> <td>Video Url:<input type="text" readonly="1" value="http://www.youtube.com/watch?v="><input type="Text" name="url"></td> </tr> <tr> <td>(Number)<input type="text" name="times" value="10"> of Times to Display Video in <input type="text" name="reloadtime" value="5">(Seconds)</td> </tr> <tr> <td>Set Width <input type="text" name="setwidth" value="425"> Set Height <input type="text" name="setheight" value="344"> </tr> <tr> <td align="center" valign="center"><input type="submit" name="action" value="Submit"></td> </tr> </form </table> Link to comment Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 The problem is the $_POST array does not contain an index called action. Replace this.... if($_POST['action'] == 'Submit') { with.... if (isset($_POST['action'])) { Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 How do i fix that? Link to comment Share on other sites More sharing options...
The Little Guy Posted December 5, 2008 Share Posted December 5, 2008 How do i fix that? Look at my previous post. Link to comment Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 Sorry, I edited my post with your fix. Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 thanks thorpe How do i make a $variable be able to be place in between text like this 123.com/123$variable123.php do i need to add 123.com/123.'$variable123'.php or something like that Link to comment Share on other sites More sharing options...
Vince889 Posted December 5, 2008 Share Posted December 5, 2008 Are you talking about GET variables? Link to comment Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 thanks thorpe How do i make a $variable be able to be place in between text like this 123.com/123$variable123.php do i need to add 123.com/123.'$variable123'.php or something like that Hard to tell from your example, so I'll give a you a few examples. $var = 'foo'; echo "this is $var bar"; echo "this is " . $var . " bar"; echo 'this is ' . $var . ' bar'; Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 sorry i wrote my example like this 123.com/123.'$variable123'.php When i meant to write it like this 123.com/123.'$variable'.123.php Link to comment Share on other sites More sharing options...
The Little Guy Posted December 5, 2008 Share Posted December 5, 2008 You have your quotes/periods switched arround, try this: '123.com/123'.$variable.'123.php' Link to comment Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 sorry i wrote my example like this 123.com/123.'$variable123'.php When i meant to write it like this 123.com/123.'$variable'.123.php Still, makes little sense. Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 ok i fixed that Next Question How do i make it so When user submits data it resubmits when page auto refreshes Link to comment Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 Firstly, forums are designed so that each question gets its own thread. Please do so. Further, you need to elaberate on your question. Why / How is the page getting auto refreshed? Link to comment Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 sorry i didnt want to make to many threads and refreshing via meta but can be changed if needed to go along with code Link to comment Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 Actually, looking at your original code I see what your trying to do. Id suggest you figure this out for yourself. Link to comment Share on other sites More sharing options...
Recommended Posts