Jump to content

Username not displaying and catagory selection


pspfreak101

Recommended Posts

I'm a little new to php but I'm building an app submiter where you enter the name of the app and select a catagory this is where I'm having problems because its coming up blank in the database and so is the username,

 

here is my code

 

 <div align="center" class="style1">Submit Your App    </div>
  <form name="form1" method="post" action="submit2.php">
App Title:<input type="text" name="app" id="app"><br>
Uploaded by: <? echo "<b>" . $_SESSION['username'] . "</b>"; ?><br>
<label>Catagory
<select name="Catagory" id="catagory">
  <option>Pc Apps</option>
  <option>Pc Games</option>
  <option>Mac Apps</option>
  <option>Mac Games</option>
  <option>Iphone/Ipod touch Apps</option>
  <option>iphone/ipod touch games</option>
  <option>Movies</option>
  <option>Operating Systems</option>
  <option>Other</option>
</select>
</label>
<br />
<label>Description
<textarea name="descrip" id="descrip" cols="50" rows="8" ></textarea></label>
<p>Download Link:
  <input type="text" name="dlink" id="dlink">
  </p>
<p>
  <label>
    I agree to terms and conditions</label>
  <input name="agree" type="checkbox" id="agree" value="yes" />
  <br>
</p>
<center><input type="Submit" name="submit" id="submit" value="submit"></center>
</form>
</div>

 

Submit2.php

<?php
// Include the database connection file.
include("connection.php");

$app=$_POST['app'];
$uploadby=$_SESSION['username'];
$catagory=$_POST['catagory'];
$descrip=$_POST['descrip'];
$dlink=$_POST['dlink'];
$agree=$_POST['agree'];

if(isset($_POST['submit'])) { 

$status = "OK";
$msg="";

// if less than one
if(!isset($app) or strlen($app) <1){
$msg=$msg."Please enter a vaild application name<BR>";
$status= "NOTOK";} 

//Check description
if(!isset($descrip) or strlen($descrip) <3){
$msg=$msg."Please Enter a Vaild description<BR>";
$status= "NOTOK";} 

//Check download link
if(!isset($dlink) or strlen($dlink) <3){
$msg=$msg."Please Enter a Vaild download link<BR>";
$status= "NOTOK";} 

//Agreement
if ($agree<>"yes") {
$msg=$msg."You must agree to terms and conditions<BR>";
$status= "NOTOK";}

if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>"; }else{ // if all validations are passed.

$query="INSERT INTO `downloads` (app, uploadby, descrip, catagory, dlink) values('$app','$uploadby','$descrip','$catagory','$dlink')";

// Perform the SQL query on the database.
$result = mysql_query($query);
// If the query failed, display an error.
if(!$result) { 
                // The dot seperates PHP code and plain text.
	echo "Your query failed. " . mysql_error();
} else {
//Display success message
echo "<font face='Verdana' size='2' color=green>You have successfully submited your app<br><br><a href=index.php>Click here to return</a><br></font>";
    } 
  }
}
?>

 

 

Archived

This topic is now archived and is closed to further replies.

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