king_of_all_burgers Posted April 21, 2008 Share Posted April 21, 2008 I'm not sure what to do but for some reason the file is not going into the folder, although the name is showing up in the db table. The folder has all permissions enabled. <?php include("settings.php"); include("header.php"); if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <!-- InstanceBeginEditable name="text_box" --> <h1 class="Head">Soccer United <br> <font color="#000000">African Team Member Fact Sheet</font> </h1> <form action="" method="post" enctype="multipart/form-data" name="join"> <p>Name*:<br /> <input name="name" type="text" id="name" size="40"> </p> <p>Age*: <input name="age" type="text" id="age" size="10" maxlength="2"> <br /> </p> <p> Location*: <br /> <input name="location" type="text" id="location" size="40"> </p> <p> Favorite Activity: <br /> <input name="activity" type="text" id="activity" size="40"> <p> Soccer Story: <br /> <textarea name="grsstory" type="text" id="grsstory" cols="40"></textarea> </p> <p>Upload Photo: <br /> <input type="file" name="pic"> <br /> </p> <p> <input type="submit" name="submit" value="submit"> <a href="thanks.html">After submitting, you'll go to this page</a></p> </form> <?php //imageupload $target = "uploads/"; $target = $target . basename( $_FILES['pic']['name']) ; $ok=1; if(move_uploaded_file($_FILES['pic']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } //endimageupload } else { // Check to see if the required fields are filled in. If not display errors. $error = 0; if ($_POST['name'] == "") { echo "Sorry, but Name was not entered. <br />"; $error = $error + 1 ; } if ($_POST['age'] == "") { echo "Sorry, but age was not entered. <br />"; $error = $error + 1; } if ($_POST['location'] == "") { echo "Sorry, but email was not entered. <br />"; $error = $error + 1; } echo "<a href=\"javascript:history.go(-1)\">Go back</a>"; // If the required fields are filled in then proceed. if ($error == 0) { // Set Variable names and get data from form and insert into database. // also checks to make sure it is good data being inserted and escapes possible injection attacks. $Fname = mysql_real_escape_string(trim($_REQUEST["name"])); $Age = mysql_real_escape_string(trim($_REQUEST["age"])); $Location = mysql_real_escape_string(trim($_REQUEST["location"])); $Activity = mysql_real_escape_string(trim($_REQUEST["activity"])); $Grsstory = mysql_real_escape_string(trim($_REQUEST["grsstory"])); $Image = mysql_real_escape_string(trim($_FILES['pic']['name'])); $MySQLquery = "INSERT INTO team_member_teammate VALUES('','$Fname','$Age','$Location','$Activity','$Grsstory','$Image')"; $results = mysql_query($MySQLquery); //Query the results // script to redirect to thanks.html page. print "<script>"; print " self.location='thanks.html';"; print "</script>"; // If there is a problem inserting into database show error. if(!$results){ echo(mysql_error()); } } } // bottom of the template do not remove. include("footer.php"); ?> Link to comment https://forums.phpfreaks.com/topic/102174-php-form-not-working-right/ Share on other sites More sharing options...
dezkit Posted April 21, 2008 Share Posted April 21, 2008 change $ok=1 ; to $ok = "1" ; <?php include("settings.php"); include("header.php"); if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <!-- InstanceBeginEditable name="text_box" --> <h1 class="Head">Soccer United <font color="#000000">African Team Member Fact Sheet</font> </h1> <form action="" method="post" enctype="multipart/form-data" name="join"> <p>Name*: <input name="name" type="text" id="name" size="40"> </p> <p>Age*: <input name="age" type="text" id="age" size="10" maxlength="2"> </p> <p> Location*: <input name="location" type="text" id="location" size="40"> </p> <p> Favorite Activity: <input name="activity" type="text" id="activity" size="40"> <p> Soccer Story: <textarea name="grsstory" type="text" id="grsstory" cols="40"></textarea> </p> <p>Upload Photo: <input type="file" name="pic"> </p> <p> <input type="submit" name="submit" value="submit"> <a href="thanks.html">After submitting, you'll go to this page[/url]</p> </form> <?php //imageupload $target = "uploads/"; $target = $target . basename( $_FILES['pic']['name']) ; $ok = "1" ; if(move_uploaded_file($_FILES['pic']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } //endimageupload } else { // Check to see if the required fields are filled in. If not display errors. $error = 0; if ($_POST['name'] == "") { echo "Sorry, but Name was not entered. "; $error = $error + 1 ; } if ($_POST['age'] == "") { echo "Sorry, but age was not entered. "; $error = $error + 1; } if ($_POST['location'] == "") { echo "Sorry, but email was not entered. "; $error = $error + 1; } echo "<a href=\"javascript:history.go(-1)\">Go back[/url]"; // If the required fields are filled in then proceed. if ($error == 0) { // Set Variable names and get data from form and insert into database. // also checks to make sure it is good data being inserted and escapes possible injection attacks. $Fname = mysql_real_escape_string(trim($_REQUEST["name"])); $Age = mysql_real_escape_string(trim($_REQUEST["age"])); $Location = mysql_real_escape_string(trim($_REQUEST["location"])); $Activity = mysql_real_escape_string(trim($_REQUEST["activity"])); $Grsstory = mysql_real_escape_string(trim($_REQUEST["grsstory"])); $Image = mysql_real_escape_string(trim($_FILES['pic']['name'])); $MySQLquery = "INSERT INTO team_member_teammate VALUES('','$Fname','$Age','$Location','$Activity','$Grsstory','$Image')"; $results = mysql_query($MySQLquery); //Query the results // script to redirect to thanks.html page. print "<script>"; print " self.location='thanks.html';"; print "</script>"; // If there is a problem inserting into database show error. if(!$results){ echo(mysql_error()); } } } // bottom of the template do not remove. include("footer.php"); ?> Link to comment https://forums.phpfreaks.com/topic/102174-php-form-not-working-right/#findComment-522985 Share on other sites More sharing options...
king_of_all_burgers Posted April 21, 2008 Author Share Posted April 21, 2008 Thanks, but for some reason it still does not work. Also I get an error message at the bottom of the page before I even upload a file saying "sorry, there was a problem uploading your file" I'm pretty confused. Link to comment https://forums.phpfreaks.com/topic/102174-php-form-not-working-right/#findComment-522998 Share on other sites More sharing options...
dezkit Posted April 21, 2008 Share Posted April 21, 2008 <?php include("settings.php"); include("header.php"); if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <!-- InstanceBeginEditable name="text_box" --> <h1 class="Head">Soccer United <font color="#000000">African Team Member Fact Sheet</font> </h1> <form action="" method="post" enctype="multipart/form-data" name="join"> <p>Name*: <input name="name" type="text" id="name" size="40"> </p> <p>Age*: <input name="age" type="text" id="age" size="10" maxlength="2"> </p> <p> Location*: <input name="location" type="text" id="location" size="40"> </p> <p> Favorite Activity: <input name="activity" type="text" id="activity" size="40"> <p> Soccer Story: <textarea name="grsstory" type="text" id="grsstory" cols="40"></textarea> </p> <p>Upload Photo: <input type="file" name="pic"> </p> <p> <input type="submit" name="submit" value="submit"> <a href="thanks.html">After submitting, you'll go to this page[/url]</p> </form> <?php } //imageupload $target = "uploads/"; $target = $target . basename( $_FILES['pic']['name']) ; $ok = "1" ; if(move_uploaded_file($_FILES['pic']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } //endimageupload } else { // Check to see if the required fields are filled in. If not display errors. $error = 0; if ($_POST['name'] == "") { echo "Sorry, but Name was not entered. "; $error = $error + 1 ; } if ($_POST['age'] == "") { echo "Sorry, but age was not entered. "; $error = $error + 1; } if ($_POST['location'] == "") { echo "Sorry, but email was not entered. "; $error = $error + 1; } echo "<a href=\"javascript:history.go(-1)\">Go back[/url]"; // If the required fields are filled in then proceed. if ($error == 0) { // Set Variable names and get data from form and insert into database. // also checks to make sure it is good data being inserted and escapes possible injection attacks. $Fname = mysql_real_escape_string(trim($_REQUEST["name"])); $Age = mysql_real_escape_string(trim($_REQUEST["age"])); $Location = mysql_real_escape_string(trim($_REQUEST["location"])); $Activity = mysql_real_escape_string(trim($_REQUEST["activity"])); $Grsstory = mysql_real_escape_string(trim($_REQUEST["grsstory"])); $Image = mysql_real_escape_string(trim($_FILES['pic']['name'])); $MySQLquery = "INSERT INTO team_member_teammate VALUES('','$Fname','$Age','$Location','$Activity','$Grsstory','$Image')"; $results = mysql_query($MySQLquery); //Query the results // script to redirect to thanks.html page. print "<script>"; print " self.location='thanks.html';"; print "</script>"; // If there is a problem inserting into database show error. if(!$results){ echo(mysql_error()); } } } // bottom of the template do not remove. include("footer.php"); ?> Try this, you forgot to close the bracket that you opened on line 4 Link to comment https://forums.phpfreaks.com/topic/102174-php-form-not-working-right/#findComment-523007 Share on other sites More sharing options...
king_of_all_burgers Posted April 21, 2008 Author Share Posted April 21, 2008 hmm now I get this error in the browser: Parse error: syntax error, unexpected '{' in african_team_form.php on line 52 Link to comment https://forums.phpfreaks.com/topic/102174-php-form-not-working-right/#findComment-523352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.