Jump to content

KC8Alen

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

KC8Alen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. yups i deleted that part already about the 2 opening mysql, because i went freak so i tried to set 2 mysql opening and hope it worked... lol for the password, i dont have a password for the mysql yet, and when i put password I get error, but im still running it local only, thanks
  2. thnx for your reply, but i've delete that part and replaced something else with it, so i didnt declare every column, and looks like its working But thank you for pointing me that out =D
  3. Hi, I have a problem with a PHP webpage i made, the problem is It doesnt show the data from the user, I've looked at it for one and a half days already but I can't seem to find the problem, it doesn't echo or print the value it gets from the database. The data it retrieves actually should be printed out on the page, but currently i'm trying to have it print in textbox value, it doesn't really matter whether its printed/echoed in textbox or not. Here is the code: <?PHP session_start(); mysql_connect("localhost", "username") or die(mysql_error()); mysql_select_db("Survey") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { header("Location: login.php"); } } } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?PHP mysql_connect("localhost", "username") or die(mysql_error()); mysql_select_db("Survey") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { header("Location: login.php"); } } } $result=mysql_query($check); $num=mysql_numrows($result); $i=0; while ($i < $num) { $username=mysql_result($result,$i,"username"); $bnaam=mysql_result($result,$i,"Bedrijfsnaam"); $kvk=mysql_result($result,$i,"Kvknr"); $tel=mysql_result($result,$i,"Telefoonnummer"); $email=mysql_result($result,$i,"Emailadres"); $contpers=mysql_result($result,$i,"Contactpersoon"); $adres=mysql_result($result,$i,"Adres"); $jaar=mysql_result($result,$i,"Jaar_van_oprichting"); $pcode=mysql_result($result,$i,"Postcode"); $plaats=mysql_result($result,$i,"Plaats"); $i++; } ?> <?PHP print $jaar;?> <!-- I've just added this random to check if it shows up... --> <table border="0"> <tr><td>Gebruikersnaam:</td><td> <input type="text" name="username" maxlength="60"> </table> <table><tr><td>_____________________________________________________</td></tr><td></td><tr><td></td></tr></table> <table> <tr><td> Bedrijfsnaam: </td> <td> <input type="text" readonly="readonly" name="bnaam" size="26" id="bnaam" value="<?PHP echo $bnaam;?>"/></td></tr> <tr><td> Contactpersoon:</td> <td><input type="text" name="contpers" size="26" id="contpers" value="<?PHP echo $contpers; ?>"/></td></tr> <tr><td> Adres: </td> <td><input type="text" name="adres" size="26" id="adres" maxlength="29" value="<? echo $adres;?>"/></td></tr> <tr><td> Postcode en plaats: </td> <td><input type="text" name="pcode" size="7" id="pcode" maxlength="7"/><input type="text" name="plaats" size="17" maxlength="26" id="plaats"/></td></tr> <tr><td> Kvk nr: </td> <td> <input type="text" name="kvk" size="18" id="kvk" maxlength="10"></td></tr> <tr><td> Telefoonnummer: </td> <td> <input type="text" name="tel" size="18" id="tel" maxlength="18"/></td></tr> <tr><td> E-mailadres: </td> <td> <input type="text" name="email" size="26" id="email" maxlength="28"/></td></tr> <tr><td> Jaar van oprichting:</td> <td><select name="jaar"> <option>Jaar</option> <option value=2010>2010</option> <option value=2009>2009</option> <option value=2008>2008</option> <option value=2007>2007</option> <option value=2006>2006</option> <option value=2005>2005</option> <option value=2004>2004</option> <option value=2003>2003</option> <option value=2002>2002</option> <option value=2001>2001</option> <option value=2000>2000</option> <option value=1999>1999</option> <option value=1998>1998</option> <option value=1997>1997</option> <option value=1996>1996</option> <option value=1995>1995</option> <option value=1994>1994</option> <option value=1993>1993</option> <option value=1992>1992</option> <option value=1991>1991</option> <option value=1990>1990</option> <option value=1989>1989</option> <option value=1988>1988</option> <option value=1987>1987</option> <option value=1986>1986</option> <option value=1985>1985</option> <option value=1984>1984</option> <option value=1983>1983</option> <option value=1982>1982</option> <option value=1981>1981</option> <option value=1980>1980</option> <option value=1979>1979</option> <option value=1978>1978</option> <option value=1977>1977</option> <option value=1976>1976</option> <option value=1975>1975</option> <option value=1974>1974</option> <option value=1973>1973</option> <option value=1972>1972</option> <option value=1971>1971</option> <option value=1970>1970</option> <option value=1969>1969</option> <option value=1968>1968</option> <option value=1967>1967</option> <option value=1966>1966</option> <option value=1965>1965</option> <option value=1964>1964</option> <option value=1963>1963</option> <option value=1962>1962</option> <option value=1961>1961</option> <option value=1960>1960</option> </select></td></tr> </table> </body> </html> Hope someone can help me out, thanks a lot.
  4. hi ignace I've looked @ page 2 but I dont see anything about retrieve POST, and it doesnt save to my MYSQL also. also, on the page 1 (form) I have an textbox to let the user type in how many uploads he/she wants to upload but, whenever i use your page two to make the page one send the form to it, it doesnt even show 1 upload box. It doesnt matter what number you fill in. This is the code of my number box, actually i copied from somewhere on the internet and made a few changes, but it worked, just the move file part.... anyways here is the code of the form for the number of uploadbox the user wants in the next coming page to show up: <form name="nxt" action="srvy1uload-.php" method="POST" onsubmit="return validator(this);"> <input name="uploadNeed" type="text" id="uploadNeed" size="2" maxlength="2" /> ( U mag maximaal 20 invullen ) <table width="803"> <td width="90%">--> Klik vervolgens op volgende om verder te gaan.</td> <input type="hidden" id="action" name="action" value="submitform" /> <td width="10%"><input type="submit" name="verzenden" id="verzenden" value="Volgende"/></td> </table> </form> Thanks
  5. Hi, thank you very much, I'll have a look at it, I really appreciate it.
  6. nvm i didnt need to set the name to ['upload'] because it already stated foreach in front of the line for: "for lus." thanks
  7. I changed the name to: <input name="userfile[<? echo $x;?>]" so i just put [] between the php echo but it now seems not to block any not allowed extensions. This is how my second page looks like (the first page is just a form and works fine so i just show the second page and third page where the problem occurs ) page 2: <html> <head><title>Uploadform</title> </head> <body><? include 'conexxion.php'; // formulier POST variabelen ophalen $bnaam = $_POST['bnaam']; $kvk = $_POST['kvk']; $tel = $_POST['tel']; $email = $_POST['email']; $contpers = $_POST['contpers']; $adres = $_POST['adres']; $jaar = $_POST['jaar']; $pcode = $_POST['pcode']; $plaats = $_POST['plaats']; $datum = date("Y-m-d"); $ip = gethostbyname($_SERVER['REMOTE_ADDR']); $abadvies = $_POST['adminadvies']; $stat = $_POST['stat']; $wie1 = $_POST['wie_1']; $kost1 = $_POST['kost_1']; $wie2 = $_POST['wie_2']; $kost2 = $_POST['kost_2']; $wie3 = $_POST['wie_3']; $kost3 = $_POST['kost_3']; $wie4 = $_POST['wie_4']; $kost4 = $_POST['kost_4']; $wie5 = $_POST['wie_5']; $kost5 = $_POST['kost_5']; // unix timestamp om het tijdstip de van de boodschap op te slaan. $time= time(); // sql insert die je in de database gaat doen $sql ="INSERT INTO Survey_1(Bedrijfsnaam, Kvknr, Telefoonnummer, Emailadres, Contactpersoon, Adres, Jaar_van_oprichting, Postcode, Plaats, Datum, IP, Admin_en_Belastingadvies, Huidige_situatie, Wie_doet_dit_1, Wat_kost_dit_1, Wie_doet_dit_2, Wat_kost_dit_2, Wie_doet_dit_3, Wat_kost_dit_3, Wie_doet_dit_4, Wat_kost_dit_4, Wie_doet_dit_5, Wat_kost_dit_5) VALUES ('".$bnaam."', '".$kvk."', '".$tel."', '".$email."', '".$contpers."', '".$adres."', '".$jaar."', '".$pcode."', '".$plaats."', '".$datum."', '".$ip."', '".$abadvies."', '".$stat."', '".$wie1."', '".$kost1."', '".$wie2."', '".$kost2."', '".$wie3."', '".$kost3."', '".$wie4."', '".$kost4."', '".$wie5."', '".$kost5."')"; //uitvoeren van de query : if (!($temp = mysql_query($sql,$connection))) showerror(); else echo("<B>Uw bedrijf met de naam ' " . $_POST['bnaam'] . " ' is opgeslagen in de database</B><br/><br/>Kies een bestand / factuur dat u wilt uploaden en druk vervolgens op volgende<P>") ?> <form name="form1" enctype="multipart/form-data" method="post" action="766.php"> <p> <? // start of dynamic form $uploadNeed = $_POST['uploadNeed']; for($x=0;$x<$uploadNeed;$x++){ ?> <!-- <P><br/><? echo $x;?><input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>"> --> <P><br/><? echo $x;?><input name="userfile[<? echo $x;?>]" type="file" id="userfile[<? echo $x;?>]"> </p> <p> <? // end of for loop } ?> <br /> </p> <p>- Indien u op de vorige pagina " 0 " heeft ingetoetst, druk dan gewoon op de onderste knop om verder te gaan.<br /> - Als u op de vorige pagina teveel heeft ingevoerd voor het uploaden negeer de rest van de uploads, u hoeft niet alle vakken te gebruiken. </p> <input style="display: none;" name="bnaam"id="bnaam" rows="1" type="hidden"><?PHP $_POST['bnaam']; ?></input><br> <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>"> <input type="submit" name="Submit" value="Bestand versturen"> <br /> <br /> * Mocht u een fout melding krijgen over email of dergelijke, ga dan terug naar de <a href="javascript:history.go(-1);">vorige</a> pagina en gebruik een andere e-mail adres, <br /> het is mogelijk dat deze al in gebruik is. </p> </form> </body> </html> Page 3: <?php // Start function \\ function handleError() { trigger_error('MY ERROR'); } // detect slash/backslash nomenclature dirname $path = dirname( __FILE__ ); $slash = '/'; (stristr( $path, $slash )) ? '' : $slash = '\\'; define( 'BASE_DIR', $path . $slash ); $folder = date("d.m.y"); // folder name //$dirPath = BASE_DIR . $folder; $dirPath = BASE_DIR . $folder; // folder path $rs = @mkdir( $dirPath, 0777 ); @handleError(); // end of function \\ $allowedExtensions = array("txt","xls","csv","doc","docx","rtf","ppt","pdf","jpg","jpeg","gif","png","bmp"); foreach ($_FILES['userfile'] as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { die($file['name'].' is niet een bruikbaar bestand voor als factuur!<br/><br/><br/> Ga terug naar de '. '<a href="javascript:history.go(-1);">'. 'vorige</a> pagina. <br/><br/><br/> Alleen de bestanden met de volgende extensies zijn toegestaan: <br/><br/>| ".csv" | ".xls" | ".txt" | ".doc" | ".docx" | ".rtf" | ".ppt" | ".pdf" | ".jpg" | ".jpeg" | ".gif" | ".png" | ".bmp" |'); } } } move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "/uploads/" . $_FILES["fileToUpload"]["name"]); ?> This thing is rlly getting me crazy, any help would really be appreciated.
  8. ah ok, thanks but now the problem is, erm how do I tell the the code to make the uploaded files to the new created map? that was also where im struggling with. :S Thanks
  9. hi guys, I'm pretty newb to php, so I was wondering if anyone could help me out with the Page below,.. I've wasted 12 hours about this thing and I cant help myself out. Anyways the problem is it looks like I can't add anything to this page, otherwise the whole page wont function, i know i haven't add a echo yet to notify the user about the successful uploaded. Also, I can't seem to get the mkdir to work with the $_POST['X'], So i thought I'd use the date(); to create a folder. I'm also googled a lot about move file and temporary file etc, but i cant seem to get it work with the script below. I've also tried to check this page out to make the server rename the file incase it will overwrite a existing file, but i get the same result, a blank page... and it wont even create the folder with date http://php.about.com/od/advancedphp/ss/rename_upload.htm I hope someone can help me out, Thanks alot!! I really appreciate it. <?php // Start function \\ function handleError() { trigger_error('MY ERROR'); } // detect slash/backslash nomenclature dirname $path = dirname( __FILE__ ); $slash = '/'; (stristr( $path, $slash )) ? '' : $slash = '\\'; define( 'BASE_DIR', $path . $slash ); $folder = date("d.m.y"); // folder name //$dirPath = BASE_DIR . $folder; $dirPath = BASE_DIR . $folder; // folder path $rs = @mkdir( $dirPath, 0777 ); @handleError(); // end of function \\ $allowedExtensions = array("txt","xls","csv","doc","docx","rtf","ppt","pdf","jpg","jpeg","gif","png","bmp"); foreach ($_FILES ++ as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { die($file['name'].' is niet een bruikbaar bestand voor als factuur!<br/><br/><br/> Ga terug naar de '. '<a href="javascript:history.go(-1);">'. 'vorige</a> pagina. <br/><br/><br/> Alleen de bestanden met de volgende extensies zijn toegestaan: <br/><br/>| ".csv" | ".xls" | ".txt" | ".doc" | ".docx" | ".rtf" | ".ppt" | ".pdf" | ".jpg" | ".jpeg" | ".gif" | ".png" | ".bmp" |'); } } } ?> (This is the code I was trying to add in my page to randomize the upload file name.) //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $ran = rand () ; //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $ran2 = $ran."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = "images/"; //This combines the directory, the random file name, and the extension $target = $target . $ran2.$ext;
×
×
  • 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.