Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. In that case it'll probably be best to revert back to your original code, but to output a new <form> for each record instead while ($redeal = mysql_fetch_row($leader)){ echo "<form action='submit-page.php' method='post' />"; // start a new form for each record echo "<input type='hidden' name='round' value='$redeal[6]' />"; echo "<tr class='innertable'>"; echo "<td><input type='radio' name='beton' value='$redeal[0]' /></td>"; echo "<td align=left>$redeal[0]($<b>".number_format($redeal[3], 2)."</b>)</td>"; echo "<td>V</td>"; echo "<td><input type='radio' name='beton' value='$redeal[1]' /></td><td align=left>$redeal[1] ($<b>".number_format($redeal[4], 2)."</b>)</td>"; echo "<td align=left><input type='radio' name='beton' value='Draw' /> $51.00</td>"; echo "<td align=left>$redeal[2]</td>"; echo "<td align=left>$redeal[7]<br />$redeal[8]</td></tr><input type='hidden' name='pwnow' value='$redeal[5]' />"; echo '<input type="submit" name="submit" value="Submit" />'; // output submit button echo "</form>"; // close form }
  2. There are few problems with your form, you have not added the enctype="multipart/form-data" attribute to your form tag. And you access the uploaded file(s) from the $_FILES superglobal not the $_POST superglobal. Have a read of the following on how PHP handles file uploads http://php.net/manual/en/features.file-upload.post-method.php The OP is storing the filename in the database, not the actual file.
  3. Remove the single quotes around '$html5' . Variables are not expanded within single quotes
  4. Because I am using mysql_fetch_row, not mysql_fetch_assoc My bad, != should of been == if($select1[0] == 0 && $select2[0] == 0) { // do insert }
  5. Nonsense. They are both do the same, except mysql_fetch_assoc returns an associative array of field names, rather than a numerically index array @OutOfInk Your form code is correct. The problem is to with how you are naming your input fields. If your form contained one record it is fine, but for having multiple records it is not. This is because you have not named your input fields with a unique name, eg you cant have two fields named the same otherwise the latter field will always override the previous fields value. This is why only the last record is received when form is posted. The solution to is to append square brackets to the field name, eg: $i = 0; while ($redeal = mysql_fetch_row($leader)){ echo "<input type='hidden' name='round[$i]' value='$redeal[6]' />"; echo "<tr class='innertable'>"; echo "<td><input type='radio' name='beton[$i]' value='$redeal[0]' /></td>"; echo "<td align=left>$redeal[0]($<b>".number_format($redeal[3], 2)."</b>)</td>"; echo "<td>V</td>"; echo "<td><input type='radio' name='beton[$i]'' value='$redeal[1]' /></td><td align=left>$redeal[1] ($<b>".number_format($redeal[4], 2)."</b>)</td>"; echo "<td align=left><input type='radio' name='beton[$i]' value='Draw' /> $51.00</td>"; echo "<td align=left>$redeal[2]</td>"; echo "<td align=left>$redeal[7]<br />$redeal[8]</td></tr><input type='hidden' name='pwnow[$i]' value='$redeal[5]' />"; $i++; } You 'll see I added [$i] to the end of the field name, this is to ensure each field carries a unique name and more importantly each record has a unique index which we can use latter on in PHP to retrieve the values for that record. Example of this would be of using a loop like foreach($_POST['round'] as $index => $value) { $round = $value; $beton = $_POST['beton'][$index]; $pwnow = $_POST['pwnow'][$index]; echo "<b>Round:</b> $round - <b>Beton:</b> $beton - <b>Pwnow:</b> $pwnow<br />"; }
  6. This tasks is for you to write the missing function called newvalue (not for someone else on the internet to do it for you). The job of the function is to change the value of $charstring from "First" to "New String". The solution is a simple one but requires the use of globals which is not recommended. It will be better if the function returned the new value instead.
  7. $element->innertext works fine for me. require_once 'simple_html_dom.php'; $html = str_get_html('<h1> <a href="http://www.theguardian.com/world/2014/mar/12/mh370-malaysia-airlines-search-expands-third-possible-sighting" class="link-text">Plane search expands after third possible sighting</a> </h1>'); foreach($html->find('a') as $element) echo '<b>Href:</b> ' . $element->href . ', <b>Link-Text:</b> ' . $element->innertext.'<br>';
  8. There are few syntax errors in your HTML. The main ones being you have not wrapped the input field values within quotes, and you have left of the > for closing the input tag. The following code is your form html fixed echo '<form action="vacaroutes.php" method="post"> <tr> <td><input type="text" name="depart" value="' . $record['Depart'] . '"></td> <td><input type="text" name="arrive1" value="' . $record['Arrive1'] . '"</td> <td><input type="text" name="name1" value="' . $record['Name1'] . '"</td> <td><input type="hidden" name="hidden" value="' . $record['Depart'] . '"></td> <td><input type="submit" name="update" value="update"></td> <td><input type="submit" name="delete" value="delete"></td> </tr> </form>'; The next major problem is your are using raw $_POST data in an SQL query. This is very dangerous and can lead to SQL injection attacks, which could allow an attacker to compromise your database. To prevent these attacks you should at least validate the user input before doing anything with it and secondly sanitize it so it can be handled safely within an SQL query.
  9. Can you post your html here (in tags)
  10. mysqli_query only returns a result set, you need to use a mysqli_fetch_* function to retrieve data from that result set, eg $result1 = mysqli_query($con,"SELECT COUNT(email) FROM kunde WHERE email = '$email'"); $select1 = mysqli_fetch_row($result1); $result2 = mysqli_query($con,"SELECT COUNT(adresse) FROM kunde WHERE adresse = '$adresse'"); $select2 = mysqli_fetch_row($result2); if($select1[0] != 0 && $select2[0] != 0) { // do insert } Alternatively you could make the email and adresse fields unique keys, then use a an INSERT IGNORE query instead
  11. A select clause does not strickly require column names to be refernced, it can be made of either column names, functions and values (wrapped in quotes).
  12. Not sure on INSERT SELECT try $sqlbestellungen = "INSERT INTO bestellungen (bestellung_id_kunde, datum, lieferzeit, bestellung, summe) SELECT id_kunde, NOW(), '$lieferzeit', '$bestellung', '$summe' FROM kunde WHERE email = '$email'";
  13. @lowheartrate Port 8080 is for your http server. In the video tutorial you linked to @2:17 for Web url you need to type in http://localhost:8080/registration_tutorial and @15:25 you type just localhost for the MySQL Server not localhost:8080. MySQL uses port 3306 by default.
  14. Try getting the link text using $element->innertext // Find all links foreach($html->find('a') as $element) echo 'Href: ' . $element->href . ', Link-Text: ' . $element->innertext.'<br>';
  15. Check $_GET['cmd'] exists using isset $cmd = isset($_GET['cmd']) ? $_GET['cmd'] : 'home'; // if $_GET['cmd'] does not exist, set $cmd to home by default
  16. explode on the | (pipe). Use foreach to loop over the returned array. In the loop start a new table row (<tr>) and a new table cell (<td>). For the current item use str_replace to replace the = with </td><td> after close the table cell (</td>) and the table row (</tr>). Code: $data = 'Length=8 in|Width=0.180 in|Thickness=|Size Group=|Bundle Diam=1.9000 in [Max]|Material=Nylon|Color=Weather Resistant'; echo '<table>'; foreach(explode('|', $data) as $item) { echo '<tr><th>'.str_replace('=', '</th><td>', $item) . '</td></tr>'; } echo '</table>';
  17. Ch0cu3r

    php logo

    To get the image dimensions download it. Or look at your browsers development console and get the dimensions that way. top left of what? Do you mean the logo in the browsers address bar (known as a fav icon) or as in the top left of the webpage like our forums logo is in the header.
  18. Ch0cu3r

    php logo

    Logo? You'd can use any image editor to create one. What specifically are you having trouble with?
  19. The psuedo code your posted would be the correct logic, which converted into PHP code would look somthing like <?php session_start(); // resume session $mysqli = new mysqli('localhost', 'user', 'pass', 'database'); // connect to mysql db $stmt = $mysqli->prepare('SELECT rank from users where name = ?'); // the query $stml->bind_param('s', $_SESSION['user']); // pass the user stored in session to the query $stmt->execute(); // execute query $stmt->bind_result($user_rank); // store the value of the rank column returned from the query iuto $user_rank variable $stmt->close(); // check the users rank if($user_rank < 3) die('Sorry you do not have the correct privilages to view this page'); // kill page, display error // display reset of page.
  20. If you want the images listed vertically instead of horizontally then remove float: left; from the css code they provided
  21. Or use fgetcsv
  22. Why? Storing the same data in multiple tables is not very good database design. What purpose does this serve?
  23. "?$id="; should be "?id=";
  24. Forgot to mention when using placeholder="<?php echo $search_langauge; ?>" you wont need value="<?php echo $search_langauge; ?>" So your search box will be just <input id="s" type="text" name="s" class="text" placeholder="<?php echo $search_language; ?>" />
  25. value= echo $search_language should be value="<?php echo $search_language; ?>" Additionally this could be replaced onblur="if(this.value == '') this.value = '$search_language';" onfocus="if(this.value == '$search_language') this.value = '';" with just placeholder="<?php echo $search_langauge; ?>"
×
×
  • 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.