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>";
    } 
  }
}
?>

 

 

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.