0

I was Looking at This Page and decided to give it a try. I am making a website that allows a user to check a phone effetely. My Only Problem is, like the asker of the original question, I get a blank screen. I went from the Selected Best Answer to attempt mine.

add.html

    <form action="add_process.php" method="POST">
        <h3>Phone Model</h3>
        <input name="model" type="text" />
        <h3>ESN/MEID</h3>
        <input name="esn" type="text" />
<br>
        <br>
                <input type="checkbox" name="wifi">WiFi<br><br>
                <input type="checkbox" name="data">Cellular Data<br><br>
                <input type="checkbox" name="call">Calling<br><br>
                <input type="checkbox" name="text">Texting<br><br>
                <input type="checkbox" name="espaeker">Ear Speaker<br><br>
                <input type="checkbox" name="rspeaker">Rear Speaker<br><br>
                <input type="checkbox" name="tmic">Top Mic<br><br>
                <input type="checkbox" name="bmic">Bottom Mic<br><br>
                <input type="checkbox" name="cport">Chargeing Port<br><br>
                <input type="checkbox" name="hport">Headphone Port<br><br>
                <input type="checkbox" name="touch">Touch Screen<br><br>
                <input type="checkbox" name="updates">System Updates<br><br>
                <input type="checkbox" name="battery">Battery<br><br>
                <input type="checkbox" name="fcamera">Forward Facing Camera<br><br>
                <input type="checkbox" name="rcamera">Rear Facing Camera<br><br>
                <input type="checkbox" name="bluetooth">Bluetooth<br><br>
                <input type="checkbox" name="lcd">LCD<br><br>
                <input type="checkbox" name="gsm">GSM Unlocked<br><br>
                <input type="checkbox" name="buttons">Buttons<br><br>
                <input type="checkbox" name="flash">Flash<br><br>
                <input type="checkbox" name="vibrator">Vibrator<br><br>
                <input type="text" cols="50" rows="10"  name="cosmetics">Cosmetic Comment<br><br>
        <input type="text" name="comments">Comments<br><br>
        <input type="submit" name="submit" value="Save Data">
    </form>

add_process.php

<?php
if (isset($_POST['model']) && isset($_POST['esn']) && isset($_POST['wifi']) && isset($_POST['data']) && isset($_POST['call']) && isset($_POST['text']) && isset($_POST['espeaker']) && isset($_POST['rspeaker']) && isset($_POST['tmic']) && isset($_POST['bmic']) && isset($_POST['cport']) && isset($_POST['hport']) && isset($_POST['touch']) && isset($_POST['updates']) && isset($_POST['battery']) && isset($_POST['facmera']) && isset($_POST['rcamera']) && isset($_POST['bluetooth']) && isset($_POST['lcd']) && isset($_POST['gsm']) && isset($_POST['buttons']) && isset($_POST['flash']) && isset($_POST['vibrator']) && isset($_POST['cosmetics']) && isset($_POST['comments'])) { // check if both fields are set

    $data = $_POST['field1'] . '-' . $_POST['field2'] . "\n";
    $ret = file_put_contents('/tmp/mydata.txt', $data, FILE_APPEND | LOCK_EX);
    if($ret === false) {
        die('There was an error writing this file');
    }
    else {
        echo "$ret bytes written to file";
    }
}
else {
   die('no post data to process');
}
Community
  • 1
  • 1
Display Word
  • 106
  • 1
  • 3
  • 11
  • 1
    Turn on error reporting in your dev environment: http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – JimL May 19 '16 at 17:33
  • you know what they say about a blank screen, *eh?* and what does this have to do with notepad++ ? – Funk Forty Niner May 19 '16 at 17:34
  • ^ I keep that one handy (edit: which is now the dupe) just for questions like these which is what's going on here with `$_POST['field1'] . '-' . $_POST['field2']`. – Funk Forty Niner May 19 '16 at 17:35
  • 1
    `isset` can take multiple values. Pass them all into one `isset`... `If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. ` -http://php.net/manual/en/function.isset.php – chris85 May 19 '16 at 17:39
  • FYI `isset` can take multiple parameters so you can do `isset($_POST['model'], $_POST['esn'], ...)` might make it a bit more readable. – ArtisticPhoenix May 19 '16 at 17:43

0 Answers0