pspfreak101 Posted October 13, 2008 Share Posted October 13, 2008 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>"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/128136-username-not-displaying-and-catagory-selection/ Share on other sites More sharing options...
unrelenting Posted October 13, 2008 Share Posted October 13, 2008 The first thing I noticed is the 'or' in the if statements. Try || for or instead. if(!isset($app) || (strlen($app) <1)) Quote Link to comment https://forums.phpfreaks.com/topic/128136-username-not-displaying-and-catagory-selection/#findComment-663635 Share on other sites More sharing options...
pspfreak101 Posted October 13, 2008 Author Share Posted October 13, 2008 that all seems to work fine its the $uploadby=$_SESSION['username']; that doesn't seem to put the person username in the databse Quote Link to comment https://forums.phpfreaks.com/topic/128136-username-not-displaying-and-catagory-selection/#findComment-663636 Share on other sites More sharing options...
Lamez Posted October 13, 2008 Share Posted October 13, 2008 when in doubt echo out! echo out the $_SESSION['username'] variable, and see if it is what you expected. Quote Link to comment https://forums.phpfreaks.com/topic/128136-username-not-displaying-and-catagory-selection/#findComment-663647 Share on other sites More sharing options...
pspfreak101 Posted October 13, 2008 Author Share Posted October 13, 2008 on the form it says your name fine but when you go to submit it in the database its empty Quote Link to comment https://forums.phpfreaks.com/topic/128136-username-not-displaying-and-catagory-selection/#findComment-663663 Share on other sites More sharing options...
Lamez Posted October 13, 2008 Share Posted October 13, 2008 instead of using $uploadby, in your mysql statement, use $_SESSION['username'] Quote Link to comment https://forums.phpfreaks.com/topic/128136-username-not-displaying-and-catagory-selection/#findComment-663693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.