Jump to content

how do i make sub pages with this code


the-botman

Recommended Posts

hi guy...

 

ok see i have this code what it does is gives the user an option to upload an image, add text, pick text position and font then pick a frame and click generate, now there are 17 frames to pick from and this floods the mobile users phone and takes very long to load the page, how do i devide this into 3 sub pages or make a drop down menu with the names of the frame and when they pick say frame 2 it must show them what the frame looks like then if they like it they can click generate,here is the code

<?php


if (isset($_FILES['image_field'])){

$handle = new upload($_FILES['image_field']);

if ($handle->uploaded) {
	if (isset($_POST['image_frame'])) {
		if ($_POST['image_frame']){
			$frame								= $_POST['image_frame'];
		    $handle->image_watermark			= $frame;
		    $handle->image_watermark_position	= 'TL';				    
		} else {
			$frame								= $_FILES['image_field']['tmp_name'];
		}	

		$frameinfo 							= getimagesize($frame);
		$newimg_w 							= $frameinfo[0];
		$newimg_h 							= $frameinfo[1];							
	}

	$filename=explode('.',$_FILES['image_field']['name']);
	$handle->file_new_name_body   = $filename[0];
	$handle->file_overwrite		  = TRUE;
    $handle->image_x              = $newimg_w;
    $handle->image_y              = $newimg_h;
    $handle->image_ratio_fill     = true;
	$handle->image_resize         = true;	    

    if ($_POST['image_text']){
	    $handle->image_text				= $_POST['image_text'];
	    $handle->image_text_font		= $_POST['text_font'];
	    $handle->image_text_position	= $_POST['text_position'];
    }
    
	//header('Content-type: ' . $handle->file_src_mime);
	//header("Content-Disposition: attachment; filename=".rawurlencode($handle->file_src_name).";");
	$handle->process(getcwd().'/output/');	

    if ($handle->processed) {
    	echo '<div class="hd2"><font color=#666666><strong><center> Your Own Personalized Image</center></strong></font></div>'."\n";
    	echo '<img alt="" src ="output/'.$handle->file_dst_name.'"><br/><br/>';
		echo '<a href="output/'.$handle->file_dst_name.'">Download</a>';
      echo '<br>'."\n";
      echo '	<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/Logo_Back.gif"></td><td>'."\n";
      echo '		<font face="Verdana" size="2"><b><a href="index.php">Back</b></font></a><br>'."\n";
      echo '<br>'."\n";
    	$handle->clean();
    } else {
    	echo 'error : ' . $handle->error;
    }
}	
exit;
}

?>
<div class="hd2"><font color=#666666><strong><center>Personalize Your Own Image</center></strong></font></div>

<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
 <table>
	 <tr>
	 	<td>Image:</td><td><input type="file" size="32" name="image_field" value=""></td>
	 </tr>
	  <tr>
	 	<td>Text:</td><td><input type="text" size="32" name="image_text" value=""></td>
	 </tr>
	  <tr>
	 	<td>Font:</td>
	 	<td>
			<select name="text_font">
				<option value="3">1</option>
				<option value="4">2</option>
				<option value="5">3</option>
				<option value="fonts/addlg10.gdf" selected="selected">4</option>
				<option value="fonts/anonymous.gdf">5</option>				
			</select>	 	
	 	</td>
	 </tr>		 
	  <tr>
	 	<td>Text Position: </td>
	 	<td>
			<select name="text_position">
				<option value=""></option>
				<option value="TL">Top Left</option>
				<option value="CL">Middle Left</option>
				<option value="BL">Bottom Left</option>
				<option value="TC">Top Center</option>
				<option value="CC">Middle Center</option>
				<option value="BC" selected="selected">Bottom Center</option>
				<option value="TR">Top Right</option>
				<option value="CR">Middle Right</option>
				<option value="BR">Bottom Right</option>				
			</select>	 	
	 	</td>
	 </tr>
	 <tr>
	 	<td colspan="2"> </td>
	 </tr>		 
	 <tr>
	 	<td colspan="2">Choose frame:</td>
	 </tr>
	 <tr>
	 	<td><input checked="checked" type="radio" name="image_frame" value="" /></td>
	 	<td>None</td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame1.gif" /></td>
	 	<td><img src="frames/frame1.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame2.gif" /></td>
	 	<td><img src="frames/frame2.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame3.gif" /></td>
	 	<td><img src="frames/frame3.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame4.gif" /></td>
	 	<td><img src="frames/frame4.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame5.gif" /></td>
	 	<td><img src="frames/frame5.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame6.gif" /></td>
	 	<td><img src="frames/frame6.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame7.gif" /></td>
	 	<td><img src="frames/frame7.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame8.gif" /></td>
	 	<td><img src="frames/frame8.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>

	 	<td><input type="radio" name="image_frame" value="frames/frame9.gif" /></td>
	 	<td><img src="frames/frame9.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame10.gif" /></td>
	 	<td><img src="frames/frame10.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame11.gif" /></td>
	 	<td><img src="frames/frame11.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>

	 	<td><input type="radio" name="image_frame" value="frames/frame12.gif" /></td>
	 	<td><img src="frames/frame12.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
	 	<td><input type="radio" name="image_frame" value="frames/frame13.gif" /></td>
	 	<td><img src="frames/frame13.gif" alt="" width="100" /></td>
	 </tr>	 
	 <tr>
 	<td><input type="radio" name="image_frame" value="frames/frame14.gif" /></td>
	 	<td><img src="frames/frame14.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>

 	<td><input type="radio" name="image_frame" value="frames/frame15.gif" /></td>
	 	<td><img src="frames/frame15.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>

	 	<td><input type="radio" name="image_frame" value="frames/frame16.gif" /></td>
	 	<td><img src="frames/frame16.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>
 	<td><input type="radio" name="image_frame" value="frames/frame17.gif" /></td>
	 	<td><img src="frames/frame17.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>

		 	<td><input type="radio" name="image_frame" value="frames/frame18.gif" /></td>
	 	<td><img src="frames/frame18.gif" alt="" width="100" /></td>
	 </tr>
	 <tr>
	<td colspan="2"><input type="submit" name="Submit" value="Generate"></td>


</tr>	 	 	 
 </table>
</form>


<?
      echo '<br>'."\n";
      echo '	<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/Logo_Back.gif"></td><td>'."\n";
      echo '		<font face="Verdana" size="2"><b><a href="../index.php">Back</b></font></a><br>'."\n";
      echo '	</td></tr>'."\n";

?>

 

i been stuck with this for days please help guy

 

Thanks in advance

The-Botman

Link to comment
Share on other sites

By more specific, I meant relating to a particular piece of code or problem. You're pretty much asking someone to do the work for you right now though; which as I said would be better suited to the freelance forum.

Link to comment
Share on other sites

Rainy morning here. Cold. Caffeine hasn't hit yet.

 

BUT, figured I'd throw out my two cents on the entire thing.

 

You need 7 Pages

Page 1 - This is your form page - 	you need 3 special fields
upload_a_ pic - this is the one you already have for getting there picture
frame_my_pic - this is a check box  it lets you know if they want a frame
text_my pic - this is a check box it lets you know if they want to add text
-----------------------------------

Page 2 - this is the first script to process your form
  get all the variables from the  form
upload and save their picture
  put all the values in session variables including the name of their picture
  if frame_my_pic was checked
	go to Page 3
elseif text_my_pic was checked
	go to page 5
else
	go to Page 7
-----------------------------------

Page 3 - this page allows them to select a frame
display max of 4 frames using pagination
make each frame a clickable link with the frame id as url passed variable
link goes to Page 4
-----------------------------------

Page 4 - this page creates the framed image
get the url passed frame id
get the image name from the SESSION variables
get the value of text_my_pic from the SESSION variables
create and save the framed image using orignal image name
if text_my_pic was checked
	go to Page 5
else
	go to Page 7

-----------------------------------
Page 5 - this page gets the text, font desired
display form for test_text_desired, font_desired, etc
go to Page 6

-----------------------------------
Page 6 - this page adds the text
get the values from Page 5 form
get image name from SESSIONS variables
create the new image saving as origial name
go to page 7

-----------------------------------
Page 7 
get all the session variables
store them in the database
do whatever you like - send to page showing the completed image, etc
---------------------------------

Link to comment
Share on other sites

$step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
if (1 === $step) {
  //code for step #1
  //store data in $_SESSION
}
else if (2 === $step) {
  //code for step #2
  //
}

 

In your form you could use:

 

<input type="hidden" name="step" value="1">

I would use a fall-through switch and save the steps in separate files to maintain some kind of structure.

Link to comment
Share on other sites

$step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
if (1 === $step) {
  //code for step #1
  //store data in $_SESSION
}
else if (2 === $step) {
  //code for step #2
  //
}

 

In your form you could use:

 

<input type="hidden" name="step" value="1">

I would use a fall-through switch and save the steps in separate files to maintain some kind of structure.

 

and how wold i go about doing that?

Link to comment
Share on other sites

$step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
// Store data in session here if submit data
switch($step)
{
    case 1:
    case 2:
    ...
        require("folder/step_". $step . ".php");
        break;
}

ofcourse you could also use a single if statement like:

$step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
// Store data in session here if submit data
if($step > 0 && $step < 5)
    require("folder/step_". $step . ".php");

Of course it's your choice what you use but 1 of these 2 might be more organized than the else-if example.

 

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.