Ok I have a register.php. And what Im trying too do is when a user uploads an image from there computer, Im trying too get that filename plus the extension and inserting it into the database. (eg: images/picture2.jpg) Would anybody know what I could do?
PHP Code:
<?php
if (isset($_FILES['imageFile'])) {
$KW_max_size=9000000000;
$extension="";
if (is_uploaded_file($_FILES['imageFile']['tmp_name'])) {
if($_FILES['imageFile']['size'] <= $KW_max_size) {
$realname = $_FILES['imageFile']['name'];
$ext_array =explode(".",$realname);
$last_position = count($ext_array) - 1;
$extension = $ext_array[$last_position];
$extAllowed=array ('all');
$ii=count($extAllowed);
$flag=0;
for($i=0;$i<$ii;$i++){
if ($extAllowed[$i]==$extension)
$flag=1;
}
if ($extAllowed[0]=="all")
$flag=1;
if(copy($_FILES['imageFile']['tmp_name'], "../../robslounge (Local Server)/ImagesUploaded/".$realname) && $flag==1) {
Header("Location: ");
} else Header("Location: ");
} else Header("Location: ");
} else Header("Location: ");
}
?>
<?php require_once('MainConnection.php'); ?>
<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="AlreadyExistName.php";
$loginUsername = $_POST['requiredusername'];
$LoginRS__query = "SELECT username FROM dbusers WHERE username='" . $loginUsername . "'";
mysql_select_db($database_MainConnection, $MainConnection);
$LoginRS=mysql_query($LoginRS__query, $MainConnection) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO dbusers (firstName, LastName, username, password, PrivledgeLevel, email, msn, yahoo, aim, icq, location, birthday, homepage, images, UserDetail, hobbiesInterest, FavQuote, RegisteredDate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['requiredfirstname'], "text"),
GetSQLValueString($_POST['requiredlastname'], "text"),
GetSQLValueString($_POST['requiredusername'], "text"),
GetSQLValueString($_POST['requiredpassword'], "text"),
GetSQLValueString($_POST['PrivledgeLevel'], "text"),
GetSQLValueString($_POST['requiredemail'], "text"),
GetSQLValueString($_POST['msn'], "text"),
GetSQLValueString($_POST['yahoo'], "text"),
GetSQLValueString($_POST['aim'], "text"),
GetSQLValueString($_POST['icq'], "text"),
GetSQLValueString($_POST['location'], "text"),
GetSQLValueString($_POST['birthday'], "text"),
GetSQLValueString($_POST['homepage'], "text"),
GetSQLValueString($_POST['imageFile'], "text"),
GetSQLValueString($_POST['UserDetail'], "text"),
GetSQLValueString($_POST['hobbiesInterest'], "text"),
GetSQLValueString($_POST['favQuote'], "text"),
GetSQLValueString($_POST['registeredDate'], "text"));
mysql_select_db($database_MainConnection, $MainConnection);
$Result1 = mysql_query($insertSQL, $MainConnection) or die(mysql_error());
$insertGoTo = "thanks.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php
//*****************************************************************
# This code is for the date according too the computers setted time
$today = date("M d Y");
//*****************************************************************
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>(((<o>_<o>))) .:.:.:.:. R e g i s t e r .:.:.:.:.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
body {
background-color: #6600FF;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
color: #CCFF00;
font-size: 10px;
font-weight: bold;
}
-->
</style>
<link href="register_design.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {font-size: 14px}
.style4 {font-size: 16px}
.style5 {font-size: 12px}
-->
</style>
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements[i]
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!")
return false
}
else
return true
}
</script>
</head>
<body>
<p align="center"><span class="style4">RULES:</span></p>
<p align="center" class="style5">When you register as a member you get the following privileges (membership is obviously free!) <br />
<br />
* view hidden content (journal) <br />
* Read and Post announcements/events<br />
* Text message Rob directly too his cell from a page<br />
* View people's penpal profiles<br />
* Birthday wishes announcements<br />
* Join Contest and win prizes!! </p>
<p align="center" class="style5">DO NOT abuse the announcements page by fluiding up useless information that is not beneficial too read</p>
<p align="center" class="style5">Do not post anything that can offended the users of this webpage (race, weight, color, religious, disabilities...)</p>
<p align="center" class="style5">If you chose too abuse any of the rules, then you will lose your membership.</p>
<p align="center" class="style5"><u>YOUR IP ADDRESS WHICH WILL GET LOGGED</u>: <b><font face="Arial, Helvetica, sans-serif" size="1" color="#6699FF">
<?php
print (' '.$REMOTE_ADDR.'.');
?>
</font></b></p>
<table width="361" border="1" bordercolor="#000000" bgcolor="#333333">
<tr>
<td>Register</td>
</tr>
</table>
<form action="/robslounge (Local Server)/account/register.php" method="POST" enctype="multipart/form-data" name="form1"" onfiltered="return checkrequired(this)"form1>
<table width="897" height="258" border="0" bordercolor="#000000">
<tr valign="top">
<td width="416" height="254"><p>* First name:
<input name="requiredfirstname" type="text" id="requiredusername" />
</p>
<p>* Last Name:
<input name="requiredlastname" type="text" id="requiredusername2" />
</p>
<p><span class="style3">*</span> username:
<input name="requiredusername" type="text" id="username4" />
</p>
<p> <span class="style3">*</span> password:
<input name="requiredpassword" type="password" id="password3" />
</p>
<p> <span class="style3">*</span> email:
<input name="requiredemail" type="text" id="email3" />
</p>
<p> msn messenger:
<input name="msn" type="text" id="email" />
</p>
<p align="right">
<input name="registeredDate" type="hidden" class="NameForm" id="registeredDate" value="<?php echo $today ?>" />
</p>
</td>
<td width="471"><p>yahoo messenger:
<input name="yahoo" type="text" id="yahoo" />
</p>
<p>aim:
<input name="aim" type="text" id="aim2" />
</p> <p>
icq:
<input name="icq" type="text" id="icq" />
</p>
<p>
location:
<input name="location" type="text" id="location" />
</p>
<p>
birthday:
<input name="birthday" type="text" id="birthday" />
</p>
<p> Homepage:
<input name="homepage" type="text" id="homepage" value="http://" />
</p>
<p>images:
<input name="imageFile" type="file" id="images" />
<br />
<br />
<input name="PrivledgeLevel" type="hidden" id="PrivledgeLevel3" value="member" />
<br />
</p></td>
</tr>
</table>
<!-- You need this script for the function too work so when the user clicks on submit
it will forward you too the Thank You Page -->
<div align="center"> <br />
<table width="783" border="0" align="left">
<tr>
<td width="9" height="228"><div align="center">
</div></td>
<td width="401" valign="top"><p>A little about you!! <br />
<textarea name="UserDetail" cols="50" rows="12" id="textarea4"></textarea>
</p>
</td>
<td width="359" valign="top"><p>Hobbies and Interest <br />
<textarea name="hobbiesInterest" cols="50" rows="12" id="textarea10"></textarea>
</p> </td>
</tr>
</table>
<p>
<input type="hidden" name="submit" value="true" />
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p align="left"> </p>
<p align="left"> </p>
<table width="825" border="0" align="left">
<tr>
<td width="32"><p> </p>
<p> </p>
<p> </p>
<p><br />
</p></td>
<td width="771" valign="top">
<div align="center">Favourite Quote!! <br />
<textarea name="favQuote" cols="50" rows="12" id="textarea20"></textarea>
<br />
<br />
<input type="submit" name="Submit" value="Submit" />
</div></td>
<td width="10"> </td>
</tr>
</table>
<p align="left"> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>
<!-- *********************************************************************************-->
<input type="hidden" name="MM_insert" value="form1">
</p>
</div>
</form>
</body>
</html>
Ok I'll reedit this post since this guy was nice in replying too my other post. But still dawg, you shouldnt come up acting a smart and $h!t just because someone doesnt understand somethin. And yes I did use the server behaviours for making my php website and you know what....there is nothing wrong with that.
And yes I did use the server behaviours for making my php website and you know what....there is nothing wrong with that.
you are right.. there is nothing wrong with it.. but.. writeing your own code makes you learn more in shorter time.. honestly i did use it also.. but trying not to becourse if i write my own i dont only learn new things.. i also know exactly what happens where.. as a suggestion i highly recommend starting to avoid useing it..