Jump to content

loxfear

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by loxfear

  1. well i fixed the missing ; but that only changed so that half of my code works. the file doesn't get uploaded. so is my approach totally wrong?
  2. ill look into it later, cant figure out how to chek for errors in sublime 2, but it must be possible ill look trough my insanly messy code and clean it up thx so much
  3. ok i added this script in the bottom of my other uploader script. what i wanted to do was, to upload an imagefile to an folder called uploads and in the same time add the name of the file to an database called uploads, together with the next id of another database i dont get any error msg, the page is just blank. <?php include 'sqlconnect.php'; $result = mysql_query(" SHOW TABLE STATUS LIKE 'aktiviteter' "); $data = mysql_fetch_assoc($result); $next_increment = $data['Auto_increment']; $sql = sprintf( "INSERT INTO aktiviteter (`title`, `firma`, `beskrivelse`, `information`, `pris`, `varighed`, `antal`, `adresse`, `by`, `postnummer`, `telefon`, `email`, `hjemmeside`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['title']), mysqli_real_escape_string($con, $_POST['firma']), mysqli_real_escape_string($con, $_POST['beskrivelse']), mysqli_real_escape_string($con, $_POST['information']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['varighed']), mysqli_real_escape_string($con, $_POST['antal']), mysqli_real_escape_string($con, $_POST['adresse']), mysqli_real_escape_string($con, $_POST['by']), mysqli_real_escape_string($con, $_POST['postnummer']), mysqli_real_escape_string($con, $_POST['telefon']), mysqli_real_escape_string($con, $_POST['email']), mysqli_real_escape_string($con, $_POST['hjemmeside']) ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "Aktiviteten er uploaded"; if(isset($_POST['upload'])) { $allowed_filetypes = array('.jpg','.jpeg','.png','.gif'); $max_filesize = 10485760; $upload_path = 'uploads/'; $targetId = $next_increment $filename = $_FILES['billede']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['billede']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['billede']['tmp_name'],$upload_path . $filename)) { $query = "INSERT INTO uploads (name, target) VALUES ($filename, $targetId)"; mysql_query($query); echo 'Your file upload was successful!'; } else { echo 'There was an error during the file upload. Please try again.'; } } mysqli_close($con);
  4. I have an Job, which i need some help with. Its an ordering system. its probably really simple to do, and i even know how i want it set up. all databases are setup. i cant pay much but my payment will be : 178.59 dollar which in this point of time is calculated from 1000 dkk the task: an ordering system which contains: selection menu - to select an activity, stored in an database an starting time textfield. just a normal textfield i guess a selection menu - for package selection- wich will find the packages in the package database with the matching target id for the selected Activity a textfield for amount of people participating, as a multiplier for the price. a selection menu - for additions selecting. same as the Package selector. and an price field this is in one row, where there should be a way to add these, so that its possible to get more acticity orderes + an Total amount field all this data should then be viewable in a table, which ill create, and after that be able to be send through an email that is setup in html, which ill make:) Why i need help: i took my hands full with this project, and im leaving soon for thailand, and that is why im a bit screwed;/ hope to hear from somone fast many thanks Joachim Gerber
  5. i dont need anything really insane, where noone can get in, just something where some standard dude cant enter but ill try looking into that
  6. hello. im trying to password protect my pages in a simple way like this: http://www.scottconnell.com/sniplets/password_protection/ but for some reason it doesnt chek the login file, so it doesnt work: <?php require_once 'login.php'; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> #form1 table tr td label { } #form1 table { text-align: left; } #wrapper { margin: 20px auto; text-align: center; font-size: 20px; } #wrapper2 { margin: 20px auto; text-align: center; font-size: 20px; } </style> </head> <body> <div id="wrapper"> --<a href="tilfojer.html">Tilføj Aktivitet</a>--<br> --<a href="tilfojtilvalg.html">Tilføj Tilvalg</a>--<br> --<a href="tilfojrestaurant.html">Tilføj Restaurant</a>--<br> --<a href="tilfojmenu.html">Tilføj Menu</a>-- </div> <div id="wrapper2"> --<a href="seaktivitet.php">Se Aktiviteter</a>--<br> --<a href="setilvalg.php">Se Tilvalg</a>--<br> --<a href="serestaurant.php">Se Restauranter</a>--<br> --<a href="semenu.php">Se Menuer</a>-- </div> </body> <a href="?logout=1">Logout</a> </html> that is how i implemented it. made the file an php file can somone tell me why it doesnt work. and maybe how to make it work, and why that works many thanks
  7. i made a submitter, that workes: <?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO aktiviteter (`title`, `firma`, `beskrivelse`, `information`, `pris`, `rabat`, `adresse`, `by`, `postnummer`, `telefon`, `hjemmeside`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['title']), mysqli_real_escape_string($con, $_POST['firma']), mysqli_real_escape_string($con, $_POST['beskrivelse']), mysqli_real_escape_string($con, $_POST['information']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['rabat']), mysqli_real_escape_string($con, $_POST['adresse']), mysqli_real_escape_string($con, $_POST['by']), mysqli_real_escape_string($con, $_POST['postnummer']), mysqli_real_escape_string($con, $_POST['telefon']), mysqli_real_escape_string($con, $_POST['hjemmeside']) ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "Aktiviteten er uploaded"; mysqli_close($con); but then i changed a few parameters and now it doesnt. i cant figure out why <?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO menus (`navn`, `kommentar`, `pris`, `target`) VALUES ('%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['navn']), mysqli_real_escape_string($con, $_POST['kommentar']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['target']), ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "menuen er uploaded"; mysqli_close($con); can anyone spot the mistake i made?
  8. Using the submitted value to look up all the other data is the biggest issue, and how to submit the data i need, or is the selecter able to do that? ps. sorry for the vague question
  9. omg .. your right .. why didnt i think of that :/
  10. Thank you, haha i should probably relook at the form ;0 but doest the values have to be inside a text input to be able to send it out?
  11. this is my code: <?php include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT * FROM aktiviteter"); $data = array(); while ($row = mysqli_fetch_assoc($sql)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], 'beskrivelse' => $row['beskrivelse'], ); } print_r(error_get_last()); ?> <html> <head> <title>Polterplanner Bestilling</title> <link rel="stylesheet" type="text/css" href="style.css"> <script> var jsArray = []; <?php foreach($data as $key => $value): echo 'jsArray["'.$key.'"] = [];'; echo "\r\n"; foreach($value as $infoType => $info): echo 'jsArray["'.$key.'"]["'.$infoType.'"] = "'.$info.'";'; echo "\r\n"; endforeach; endforeach; print_r(error_get_last()); ?> function activitySelectionChanged(elementID) { var activitySelect = document.getElementById('activity' + elementID); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice' + elementID); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; var price1 = document.getElementById('activityPrice').innerHTML; var price2 = document.getElementById('activityPrice2').innerHTML; var total = document.getElementById('activityTotal'); if(price1!='Pris' && price2!='Pris') { total.innerHTML = parseInt(price1) + parseInt(price2); } } </script> </head> <body> <div id"wrapper"> <div id="tableWrapper"> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="23"> <select class="styled-select" name="activity" id="activity" onChange="activitySelectionChanged('')"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; endforeach; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityPrice">Pris</span>,-</td> </tr> </table> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="23"> <select class="styled-select" name="activity2" id="activity2" onChange="activitySelectionChanged(2)"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; print_r(error_get_last()); endforeach; ?> </select></td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityPrice2">Pris</span>,-</td> </tr> </table> <table class="tables" width="349" height="27" border="0"> <tr> <td width="174" height="27">Total:</td> <td width="86"> </td> <td width="75"><span class="Pris" id="activityTotal">Total</span>,-</td> </tr> </table> </div> <!-- tableWrapper ends --> </div> <!-- wrapper ends --> </body> </html> what i want is the info send through a form, so that im ale to send this via an email. would i use: document.getElementById( ...... ); ? link to working page: http://polterplanner.dk/bestiller.php
  12. coool dude can u explain to me why the endforeach didnt make any problems the first time?
  13. so like this:? <?php include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT * FROM aktiviteter"); $data = array(); while ($row = mysqli_fetch_assoc($sql)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], 'beskrivelse' => $row['beskrivelse'], ); } print_r(error_get_last()); ?> <html> <head> <title>AWESOMEE</title> <script> var jsArray = []; <?php foreach($data as $key => $value): echo 'jsArray["'.$key.'"] = [];'; echo "\r\n"; foreach($value as $infoType => $info): echo 'jsArray["'.$key.'"]["'.$infoType.'"] = "'.$info.'";'; echo "\r\n"; endforeach; endforeach; print_r(error_get_last()); ?> function activitySelectionChanged(elementID) { var activitySelect = document.getElementById('activity' + elementID); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice' + elementID); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; var price1 = document.getElementById('activityPrice').innerHTML; var price2 = document.getElementById('activityPrice2').innerHTML; var total = document.getElementById('activityTotal'); if(price1!='Pris' && price2!='Pris') { total.innerHTML = parseInt(price1) + parseInt(price2); } } </script> </head> <body> <table width="349" height="27" border="0"> <tr> <td width="174" height="23"><select name="activity" id="activity" onChange="activitySelectionChanged('')"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; endforeach; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span id="activityPrice">Pris</span>,-</td> </tr> <tr> <td width="174" height="23"><select name="activity2" id="activity2" onChange="activitySelectionChanged(2)"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span id="activityPrice2">Pris</span>,-</td> </tr> <tr> <td>Total:</td> <td></td> <td><span id="activityTotal"></span></td> </tr> </table> </body> </html> endforeach; sadly that isnt working. when u say the funktion that gets called, then that would be the onchange funktion right?
  14. i have this code, wich makes me able to get a price for a server and display it in a selection menu : http://polterplanner.dk/bestiller.php what i need is a way to make it able to get a sum of the two prices, displayed in another span, and every time the prices changes it should recalculate, <?php include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT * FROM aktiviteter"); $data = array(); while ($row = mysqli_fetch_assoc($sql)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], 'beskrivelse' => $row['beskrivelse'], ); } print_r(error_get_last()); ?> <html> <head> <title>AWESOMEE</title> <script> var jsArray = []; <?php foreach($data as $key => $value): echo 'jsArray["'.$key.'"] = [];'; echo "\r\n"; foreach($value as $infoType => $info): echo 'jsArray["'.$key.'"]["'.$infoType.'"] = "'.$info.'";'; echo "\r\n"; endforeach; endforeach; print_r(error_get_last()); ?> function activitySelectionChanged() { var activitySelect = document.getElementById('activity'); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice'); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; } function activitySelectionChanged2() { var activitySelect = document.getElementById('activity2'); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice2'); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; } </script> </head> <body> <table width="349" height="27" border="0"> <tr> <td width="174" height="23"><select name="activity" id="activity" onChange="activitySelectionChanged()"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; endforeach; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span id="activityPrice">Pris</span>,-</td> </tr> <tr> <td width="174" height="23"><select name="activity2" id="activity2" onChange="activitySelectionChanged2()"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; print_r(error_get_last()); ?> </select></td> <td width="86"> </td> <td width="75"><span id="activityPrice2">Pris</span>,-</td> </tr> </table> </body> </html> endforeach; hope you are able to direct me to something that will help me thanks
  15. now how do i make it echo the pris row beside the select ?
  16. i did see ur reply <?php include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT * FROM aktiviteter"); $data = array(); while ($row = mysqli_fetch_assoc($sql)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], ); } ?> <select name="country"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select> atm it sees the array, and therefor there will be, array in the list, but what i need is the title of every row in there, its prob not that easy echo '<option value="'.$key.'">'.$value['title'].'</option>'; only shows one title ;/
  17. what i need is an array with arrays inside, i want to be able to select the arrays inside the array, and when that is selected i want the data in that to be shown, but for now, i need the arrays to be shown in the select list menu
  18. im getting the data from my sql server, putting it into an array and then i want the selection list to show the array
  19. nothing gets put into the select list <?php include 'sqlconnect.php'; $data = array(); while ($row = mysqli_fetch_assoc($result)) { $data[$row['id']] = array( 'title' => $row['title'], 'pris' => $row['pris'], ); } ?> <select name="country"> <option value="">-----------------</option> <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value.'</option>'; //close your tags!! endforeach; ?> </select> how do i get this to work-?
  20. good point, an array with the arrays inside i will chek this out tomorrow thank you a lot ! ill remember to mark it as solved if i solve it ;P
  21. so i want $data to be the id of the row, and the array to be filled with the information of the columns like : $row['id'] = array( 'Title' => '$row["title"]', 'Beskrivelse' => '$row["beskrivelse"]', 'Pris' => '$row["pris"]', just dont think that would workbecaus of the id
×
×
  • 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.