Jump to content

Recommended Posts

Hello everyone. Certainly do appreciate that this forum exists!

What I need to do is insert in this form an image upload script, that when submitted, returns the web address of the upload image as a text input field on the form. have dabbled with a few upload scripts, but not sure really how to do this. Here is the form without anything added.

 

<?
//////ENTRY PAGE 2//////

//////CONFIGURATION//////
global $scripturl;
$query = "SELECT `memberName` FROM `smf_members` WHERE `ID_GROUP` IN (1, 9, 10, 11, 13) ORDER BY `memberName`;";
$result = mysql_query($query);

/////ENTRY FORM 2/////

//DISPLAY THE FORM
if (isset($_POST['submitted'])) {
echo'
<form action="'.$scripturl.'?page=183'.$GET['page'].'" method="post">
<INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />';
//HOSTING INFORMATION
echo'
<hr style="width: 100%; height: 2px;" />
<h4>HOSTING INFORMATION</h4><hr style="width: 100%; height: 2px;" />';

	//Race Information From Page 1
	echo'
	<table>
	<tr><td><p><b>HOST :</b></P><input type="text" READONLY name="host" value="' . $_POST['host'] . '" /></td></tr>
	<tr><td><p><b>DATE :</b></P><input type="text" READONLY name="date" value="' . $_POST['date'] . '" /></td></tr>
	<tr><td><p><b>Number of Boats :</b></P><input type="text" READONLY name="boats" value="' . $_POST['boats'] . '" /></td></tr>
	<tr><td><p><b>Number of Boats :</b></P><input type="text" READONLY name="series" value="' . $_POST['series'] . '" /></td></tr>
	<tr><td><p><b>Race Factor :</b></P><input type="text" READONLY name="factor" value="' . $_POST['factor'] . '" /></td></tr>
	</table>';

//INPUT RESULTS
echo'		
<hr style="width: 100%; height: 2px;" />
<h4>ENTER RESULTS</h4>
<hr style="width: 100%; height: 2px;" />';
	//Setup Loop
	$times = $_POST['boats'];
	$x = 0;
	while ($x < $times) {

	//SELECT PLAYER NAME
	echo'
	<table><tr><td><SELECT id="name" name="name[ ]" style="WIDTH: 160px" value ="';
		echo '" />';//this creates the dropdown list for member selection
		if(mysql_num_rows($result)) {
		while($row = mysql_fetch_row($result))
		{
		print("<option value=\"$row[0]\">$row[0]</option>");
		}
		} 
		mysql_data_seek($result, 0);
	echo'</td>';

	//SELECT FINISH POSITION

	echo'
	<td><SELECT id="points" name="points[ ]" style="WIDTH: 60px" value ="';
		echo '" />
		<OPTION value="DNF" selected>DNF</OPTION>
		<OPTION value="DNS">DNS</OPTION>
		<OPTION value="1">1</OPTION>
		<OPTION value="2">2</OPTION>
		<OPTION value="3">3</OPTION>
		<OPTION value="4">4</OPTION>
		<OPTION value="5">5</OPTION>
		<OPTION value="6">6</OPTION>
		<OPTION value="7">7</OPTION>
		<OPTION value="8">8</OPTION>
		<OPTION value="9">9</OPTION>
		<OPTION value="10">10</OPTION>
		<OPTION value="11">11</OPTION>
		<OPTION value="12">12</OPTION>
		<OPTION value="13">13</OPTION>
		<OPTION value="14">14</OPTION>
		<OPTION value="15">15</OPTION>
		<OPTION value="16">16</OPTION>
		<OPTION value="17">17</OPTION>
		<OPTION value="18">18</OPTION>
		<OPTION value="19">19</OPTION>
		<OPTION value="20">20</OPTION>
		<OPTION value="21">21</OPTION>
		<OPTION value="22">22</OPTION>
		<OPTION value="23">23</OPTION>
		<OPTION value="24">24</OPTION>
		<OPTION value="25">25</OPTION>
		<OPTION value="26">26</OPTION>
		<OPTION value="27">27</OPTION>
		<OPTION value="28">28</OPTION>
		<OPTION value="29">29</OPTION>
		<OPTION value="30">30</OPTION>
		</SELECT></td>
		</tr>';
	$x++;
	}

	//SUBMIT SCREENSHOT

	//FINALLY SUBMIT
	echo'
	<tr>
	<td><INPUT type="submit" value="Submit"><INPUT type="reset" value="Reset"></td>
	</tr>
	</table></form>';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/84191-image-upload-question/
Share on other sites

this is what I have now:

<?
//////ENTRY PAGE 2//////

//////CONFIGURATION//////
global $scripturl;
$query = "SELECT `memberName` FROM `smf_members` WHERE `ID_GROUP` IN (1, 9, 10, 11, 13) ORDER BY `memberName`;";
$result = mysql_query($query);

/////ENTRY FORM 2/////

//DISPLAY THE FORM
if (isset($_POST['submitted'])) {
echo'
<form action="'.$scripturl.'?page=183'.$GET['page'].'" method="post">
<INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />';
//HOSTING INFORMATION
echo'
<hr style="width: 100%; height: 2px;" />
<h4>HOSTING INFORMATION</h4><hr style="width: 100%; height: 2px;" />';

	//Race Information From Page 1
	echo'
	<table>
	<tr><td><p><b>HOST :</b></P><input type="text" READONLY name="host" value="' . $_POST['host'] . '" /></td></tr>
	<tr><td><p><b>DATE :</b></P><input type="text" READONLY name="date" value="' . $_POST['date'] . '" /></td></tr>
	<tr><td><p><b>Number of Boats :</b></P><input type="text" READONLY name="boats" value="' . $_POST['boats'] . '" /></td></tr>
	<tr><td><p><b>Number of Boats :</b></P><input type="text" READONLY name="series" value="' . $_POST['series'] . '" /></td></tr>
	<tr><td><p><b>Race Factor :</b></P><input type="text" READONLY name="factor" value="' . $_POST['factor'] . '" /></td></tr>
	</table>';

//INPUT RESULTS
echo'		
<hr style="width: 100%; height: 2px;" />
<h4>ENTER RESULTS</h4>
<hr style="width: 100%; height: 2px;" />';
	//Setup Loop
	$times = $_POST['boats'];
	$x = 0;
	while ($x < $times) {

	//SELECT PLAYER NAME
	echo'
	<table><tr><td><SELECT id="name" name="name[ ]" style="WIDTH: 160px" value ="';
		echo '" />';//this creates the dropdown list for member selection
		if(mysql_num_rows($result)) {
		while($row = mysql_fetch_row($result))
		{
		print("<option value=\"$row[0]\">$row[0]</option>");
		}
		} 
		mysql_data_seek($result, 0);
	echo'</td>';

	//SELECT FINISH POSITION

	echo'
	<td><SELECT id="points" name="points[ ]" style="WIDTH: 60px" value ="';
		echo '" />
		<OPTION value="DNF" selected>DNF</OPTION>
		<OPTION value="DNS">DNS</OPTION>
		<OPTION value="1">1</OPTION>
		<OPTION value="2">2</OPTION>
		<OPTION value="3">3</OPTION>
		<OPTION value="4">4</OPTION>
		<OPTION value="5">5</OPTION>
		<OPTION value="6">6</OPTION>
		<OPTION value="7">7</OPTION>
		<OPTION value="8">8</OPTION>
		<OPTION value="9">9</OPTION>
		<OPTION value="10">10</OPTION>
		<OPTION value="11">11</OPTION>
		<OPTION value="12">12</OPTION>
		<OPTION value="13">13</OPTION>
		<OPTION value="14">14</OPTION>
		<OPTION value="15">15</OPTION>
		<OPTION value="16">16</OPTION>
		<OPTION value="17">17</OPTION>
		<OPTION value="18">18</OPTION>
		<OPTION value="19">19</OPTION>
		<OPTION value="20">20</OPTION>
		<OPTION value="21">21</OPTION>
		<OPTION value="22">22</OPTION>
		<OPTION value="23">23</OPTION>
		<OPTION value="24">24</OPTION>
		<OPTION value="25">25</OPTION>
		<OPTION value="26">26</OPTION>
		<OPTION value="27">27</OPTION>
		<OPTION value="28">28</OPTION>
		<OPTION value="29">29</OPTION>
		<OPTION value="30">30</OPTION>
		</SELECT></td>
	</tr></table>';
	$x++;
	}

	//SUBMIT SCREENSHOT
	echo'	
	<hr style="width: 100%; height: 2px;" />
	<h4>SUBMIT SCREENSHOT</h4>
	<hr style="width: 100%; height: 2px;" />';

	echo'
	<form name="form1" method="post" action="" enctype="multipart/form-data">
	<input type="file" name="imagefile">
	<br>
	<input type="submit" name="Upload" value="Upload">
	</form>';

	if(isset($_POST['Upload'] ))
	{
		if ($_FILES['imagefile']['type'] == "image/png"){
			copy ($_FILES['imagefile']['tmp_name'], "screenshots/".$_FILES['imagefile']['name']) 
			or die ("Could not copy");
			echo ' 
			<table>
			<tr><td>
			<p><b>IMAGE ADDRESS :</b></P>
			<input type="text" READONLY name="image" value="http://vsk-ayc.totalh.com/screenshots/' . $_FILES['imagefile']['name'] . '" />
			</td></tr>
			</table>';
			}
		else {
			echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>";
			}
	}

	//FINALLY SUBMIT
	echo'
	<hr style="width: 100%; height: 2px;" />
	<h4>SUBMIT RESULTS</h4>
	<hr style="width: 100%; height: 2px;" />
	<table>
	<tr>
	<td><INPUT type="submit" value="Submit"><INPUT type="reset" value="Reset"></td>
	</tr>
	</table></form>';
}
?>

 

The problem I am having is that when the "upload" button is pressed, it advances to the next page rather than staying on the current page.

Link to comment
https://forums.phpfreaks.com/topic/84191-image-upload-question/#findComment-428766
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.