flemingmike Posted June 18, 2010 Share Posted June 18, 2010 error is on line <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> code below <?php //If we submitted the form if(isset($_POST['submitMe'])) { echo '<div id="musicinfo" align="center"> <table border="1" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <center> <input type="text" name="name"size="24"> <input type="submit" value="Search" name="submitMe"> </form> </td> </tr> </table> </div>'; $hmm = simplexml_load_file('http://www.durhamit.ca:8181/1.0/?method=database.search&searcharg='.$_POST['name'] .''); foreach($hmm->tracks->track as $tracks) { $artist = $tracks->artist; $title = $tracks->title; $album = $tracks->album; $id = $tracks->id; echo '<table border="1" width="60%" align="center">'; echo '<tr>'; echo '<td width="25%">'.$artist.'</td>'; echo '<td width="25%">'.$title.'</td>'; echo '<td width="25%">'.$album.'</td>'; echo '<td width="25%"><a href="http://www.durhamit.ca:8181/1.0/?method=player.playDatabaseItem&id='.$id.'">Play</a></td>'; echo '</tr>'; echo '</table>'; } } //If we haven't submitted the form else { ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <center> <input type="text" name="name"size="24"> <input type="submit" value="Search" name="submitMe"> </form> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/205187-error-on-line-15/ Share on other sites More sharing options...
Maq Posted June 18, 2010 Share Posted June 18, 2010 Instead of echoing out the HTML why don't you just break out of PHP, display the HTML and break back in? //If we submitted the form if(isset($_POST['submitMe'])) { ?> ; // Rest of code Quote Link to comment https://forums.phpfreaks.com/topic/205187-error-on-line-15/#findComment-1074010 Share on other sites More sharing options...
Pikachu2000 Posted June 18, 2010 Share Posted June 18, 2010 As I stated in the last thread that included this code, get rid of the short open tags, and quick echo tag syntax, and replace them with long open tags and proper echo syntax. And while you're at it, you can simply leave the form's 'action=' attribute blank if it submits to itself. Quote Link to comment https://forums.phpfreaks.com/topic/205187-error-on-line-15/#findComment-1074012 Share on other sites More sharing options...
Alex Posted June 18, 2010 Share Posted June 18, 2010 And while you're at it, you can simply leave the form's 'action=' attribute blank if it submits to itself. Yea, this is a much better idea. Using $_SERVER['PHP_SELF'] leaves you open to XSS attacks. Or if you want it to be 'valid' you can just put the name of the file. Quote Link to comment https://forums.phpfreaks.com/topic/205187-error-on-line-15/#findComment-1074034 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.