Jump to content

Selecting photos from 2 form


jameshay

Recommended Posts

Hi,I am a beginner in php. And I am trying to create this php program where a user selects a picture and it displays it! Theare is an input page which is html and an processing page which is php! I seemes to have a problem in the processing page of the program.

 

The problem is on line 22 in the processing page and it relates to escape character. How do I fix my issue please help I alredy spend more the several hours on it and still can't figure it out!

 

Here are the code for the processing page:

 

<?php
if(isset($_POST['Random']))
{
$Random = rand(0,12)." .jpg";
Print "<img src=\ "Photos/$Random\"
alt="Smiley face"height="50%" width="50%" border="5" <br/>";
//Problem with escape character heare don't know how to fix it!
}
else
{
if (isset($_POST['Anime']))
{
$Arr=$_POST['Anime'];
displayPhotos($Arr);
}
else
{
echo "You need to select photo.<br />";
}
function displayPhotos($Arr)
{
foreach ($Arr as $element)
{
print " <br/>";
Switch ($element){
Case 1:
    echo "<img src="Photos/1.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 2:
    echo "<img src="Photos/2.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 3:
    echo "<img src="Photos/3.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 4:
    echo "<img src="Photos/4.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 5:
    echo "<img src="Photos/5.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 6:
    echo "<img src="Photos/6.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 7:
    echo "<img src="Photos/7.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 8:
    echo "<img src="Photos/8.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 9:
    echo "<img src="Photos/9.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 10:
    echo "<img src="Photos/10.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 11:
    echo "<img src="Photos/11.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
Case 12:
    echo "<img src="Photos/12.jpg" alt="Smiley face"
    height="50%" width="50%" border="5" <br/>";
    break;
    }
  }
    
}    

}

?><!--End PHP Script-->

[b]* Can someone also look at the rest of the code and tell me whats wrong and fix it for me Thank You!

Here is the input page incase anyone needs to lok at to solve the processing page codes:[/b]


<i>Please click any checkboxes to select a photo!</i>
<script type="text/javascript" language="javascript">// <![CDATA[
function checkAll(formName, checktoggle)
{
  var checkboxes = new Array();
  checkboxes = document[formName].getElementsByTagName('input');
 
  for (var i=0; i<checkboxes.length; i++)  {
    if (checkboxes[i].type == 'checkbox')   {
      checkboxes[i].checked = checktoggle;
    }
  }
}
// ]]></script>

<fieldset>
<a onclick="javascript:checkAll('getIt', true);"
href="javascript:void();">check all</a>
<a onclick="javascript:checkAll('getIt', false);"
href="javascript:void();">uncheck all</a><br/>
<form  action="Process_Page of the Project.php" method="post" name="getIt">
<input type="checkbox" name="Anime[]" value="1" />Code Geass Lelouch Of The Rebellion<br/>
<input type="checkbox" name="Anime[]" value="2" />Death Note<br/>
<input type="checkbox" name="Anime[]" value="3" />A Certain Magical Index<br/>
<input type="checkbox" name="Anime[]" value="4" />Kaze No Stigma<br/>
<input type="checkbox" name="Anime[]" value="5" />One Piece<br/>
<input type="checkbox" name="Anime[]" value="6" />Trigun<br/>
<input type="checkbox" name="Anime[]" value="7" />Tengen Toppa Gurren Lagann<br/>
<input type="checkbox" name="Anime[]" value="8" />Prince Of Tennis<br/>
<input type="checkbox" name="Anime[]" value="9" />Fairy Tail<br/>
<input type="checkbox" name="Anime[]" value="10" />Katekyo Hitman Reborn<br/>
<input type="checkbox" name="Anime[]" value="11" />Bleach<br/>
<input type="checkbox" name="Anime[]" value="12" />Silver Spoon(Gin no Saji)<br/><br/>


<input type="submit" name="formSubmit" value="Submit Choices" />  
</form>
</fieldset>
<br/>
<fieldset>

<form action="Process_Page of the Project.php" method="post">
You can also click the Random button to view a random photo.<br/><br/>
<button name="Random" type="submit" value="R"> Randomize Me!</button>
</form>
</fieldset>

</p>
</body>
</html>
Edited by requinix
please use [code] tags when posting code
Link to comment
Share on other sites

Well I stopped here, but I feel like this isnt the only problem.


Print "<img src=\ "Photos/$Random\"
alt="Smiley face"height="50%" width="50%" border="5" <br/>";
//Problem with escape character heare don't know how to fix it!

why is there a <br/> inside your image tag? also you need to use quotes correctly.

 

It should probably look more like

echo "<img src=\'Photos/$Random\' alt='Smiley face' height='50%' width='50%' border='5' /><br/>";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.