sensenmercado / jpegcam

Automatically exported from code.google.com/p/jpegcam
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Save image same with the value of the form #52

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
                <form name="webcam_buttons" method="GET" action="test.php">
                <span><p>ID number</p><input type="textbox" value='<?php echo $id_number; ?>' name="id_number2"></input></span>
    <!--                <input type=button value="Configure..." onClick="webcam.configure()">-->
                &nbsp;&nbsp;&nbsp;
                <input type="Submit" value="Capture" onClick="webcam.snap()">
                &nbsp;&nbsp;&nbsp;
    <!--            <input type=button value="Reset" onClick="webcam.reset()"> -->
            </form>

<?php

require_once 'post_id.php';

$id_number = $_GET['id_number2'] . '.jpg';

//$filename = date('YmdHis') . '.jpg';
$filename = $id_number;
$result = file_put_contents($filename, file_get_contents('php://input'));
if (!$result) {
    echo "Can't save image $filename \n";
    exit();
}

$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . 
'/' . $filename;
print "$url\n";
?>

Original issue reported on code.google.com by alyssa3b...@gmail.com on 16 Feb 2012 at 5:08

GoogleCodeExporter commented 8 years ago
can you please help me here I want save an image but the file name should be 
same with the value name of the form here is my code

Original comment by alyssa3b...@gmail.com on 16 Feb 2012 at 5:10

GoogleCodeExporter commented 8 years ago
use following code

<form action="user_insert.php" method="post">
            <div class="formFields">
                <div class="lbl"><label>Full Name: </label></div>
                <div class="txtlbl"><input type="text" name="fullname" autocomplete="off" /></div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Father's Name: </label></div>
                <div class="txtlbl"><input type="text" name="fname" autocomplete="off" /></div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Mother's Name: </label></div>
                <div class="txtlbl"><input type="text" name="mname" autocomplete="off" /></div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Present Adress:</label></div>
                <div class="txtlbl"><textarea name="present" rows="2" cols="30" autocomplete="off"></textarea></div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Permanent Adress:</label></div><div class="txtlbl"><textarea name="permanent" rows="2" cols="30" autocomplete="off"></textarea></div></div><br>
            <div class="formFields"><div class="lbl"><label>Marital Status:</label></div><div class="txtlbl"><select name="marital">
            <option value="married">Married</option>
            <option value="Single">Single</option>
            <option value="Widow">Widow</option>
            </select></div></div><br>
            <div class="formFields"><div class="lbl"><label>Religion:</label></div><div class="txtlbl"><select name="religion">
            <option value="muslim">Muslim</option>
            <option value="hindhu">Hindhu</option>
            <option value="khristan">Khristan</option>
            <option value="budho">Budho</option>
            </select></div></div><br>
            <div class="formFields"><div class="lbl"><label>Gender:</label></div><div class="txtlbl"><select name="gender">
            <option value="male">Male</option>
            <option value="female">Female</option>
            </select></div></div>
            <div class="formFields">
                <div class="lbl"><label> Date of Birth:</label></div>
                <div class="txtlbl">
                    <select name="yearOfBirth">
                        <option value="">year</option>
                        <?php for ($i = 1980; $i < date('Y'); $i++) : ?>
                            <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php endfor; ?>
                    </select>
                    <select name="monthOfBirth">
                        <option value="">month</option>
                        <?php for ($i = 1; $i <= 12; $i++) : ?>
                        <option value="<?php echo ($i < 10) ? '0'.$i : $i; ?>"><?php echo $i; ?></option>
                        <?php endfor; ?>
                    </select>
                    <select name="dateOfBirth">
                        <option value="">date</option>
                        <?php for ($i = 1; $i <= 31; $i++) : ?>
                            <option value="<?php echo ($i < 10) ? '0'.$i : $i; ?>"><?php echo $i; ?></option>
                        <?php endfor; ?>
                    </select>
                </div>
            </div>
            <div class="formFields">
            <div class="lbl"><label>Country:</label></div>
            <div class="txtlbl"><input type="text" name="country" autocomplete="off"></div>
            </div>
            <div class="formFields">
            <div class="lbl"><label>Contact Number:</label></div>
            <div class="txtlbl"><input type="text" name="contact" autocomplete="off"></div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Last Education:</label></div>
                <div class="txtlbl">
                <select name="education">
                    <option value="psc">PSC</option>
                    <option value="jsc">JSC</option>
                    <option value="ssc">SSC</option>
                    <option value="hsc">HSC</option>
                    <option value="bschnours">B.Sc(Hns)</option>
                    <option value="bcom">Bcom</option>
                </select>
                </div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Security Question:</label></div>
                <div class="txtlbl">
                <select name="securityqus">
                    <option value="mname">What is your mother name? </option>
                    <option value="fname">What is your father name?</option>
                </select>
                </div>
            </div>

            <div class="formFields">
                <div class="lbl"><label> Answer:</label></div>
                <div class="txtlbl"><input type="text" name="answer" autocomplete="off"></div>
            </div>

            <div class="formFields">
                <div class="lbl"><label>E-mail:</label></div>
                <div class="txtlbl"><input type="text" name="email" autocomplete="off"></div>
            </div>
            <div class="formFields">
                <div class="lbl"><label>Password:</label></div>
                <div class="txtlbl"><input type="password" name="pass" autocomplete="off"></div>
            </div>
            <div class="formFields">
                <div class="camerabox">
                    <script language="JavaScript">
                        document.write( webcam.get_html(320, 240) );//dimensiones de la camara
                    </script><br />
                    <input type=button value="Capture" onClick="webcam.freeze()">
                    <input type=button value="Upload" onClick="do_upload()">
                </div>
                <div class="cameraresultbox">
                    <div id="upload_results" style="background-color:#eee;"></div>
                </div>
                <script language="JavaScript">
                        webcam.set_hook( 'onComplete', 'my_completion_handler' );

                        function do_upload() {
                            // upload to server
                            document.getElementById('upload_results').innerHTML = '<h1>Uploading...</h1>';
                            webcam.upload();
                        }

                        function my_completion_handler(msg) {
                            // extract URL out of PHP output
                            if (msg.match(/(http\:\/\/\S+)/)) {
                                var image_url = RegExp.$1;
                                document.getElementById('photo').value=image_url
                                // show JPEG image in page
                                document.getElementById('upload_results').innerHTML =
                                    '<img src="' + image_url + '">';
                                //webcam.reset();
                            }
                            else alert("PHP Error: " + msg);
                        }
                    </script>                              
            </div>
            <input id="photo" type="hidden" name="imageurl" value="" /><br /><br /><br />
            <div class="clear1"></div>
            <input type="submit" name="button" id="button" value="Submit"/>
            </form>

and

<?php
    $username = "root";
    $password = "";//Bd@akmSh10
    $hostname = "localhost";//114.130.38.37

    $fullname = $_POST['fullname'];
    $fname = $_POST['fname'];
    $mname = $_POST['mname'];
    $present = $_POST['present'];
    $permanent = $_POST['permanent'];
    $marital = $_POST['marital'];
    $religion = $_POST['religion'];
    $gender = $_POST['gender'];
    $country = $_POST['country'];
    $contact = $_POST['contact'];
    $education = $_POST['education'];
    $question = $_POST['securityqus'];
    $answer = $_POST['answer'];
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $photourl = $_POST['imageurl'];
    $yearOfBirth = $_POST['yearOfBirth'];
    $monthOfBirth = $_POST['monthOfBirth'];
    $dateOfBirth = $_POST['dateOfBirth'];
    //$id = $_POST['id_foto'];
       // echo $pass;
        //echo $id;
       // if ($yearOfBirth != '' && $monthOfBirth != '' && $dateOfBirth != '') {
            // Generate date of birth in format of YYYY-mm-dd
            // $dob = $yearOfBirth.'-'.$monthOfBirth.'-'.$dateOfBirth;
       // }
        //echo $dob;
       $con = mysql_connect($hostname, $username, $password)
         or die("Unable to connect to MySQL");
         mysql_select_db("webcam", $con);
         //if(mysql_select_db("fotos", $con)){echo "connect db";}
         //if(isset($con)){echo "connect";}
         // echo "is here";

       if(isset($_POST['button'])) {

                //echo "check";
                //$forquery="select * from fotos";

                $forquery = "INSERT INTO fotos(fullname, fname, mother, present, permanent, marital, religion, gender, country, contact, education, answer, email, password, imageurl)
                VALUES('$fullname', '$fname','$mname','$present','$permanent', '$marital', '$religion','$gender', '$country', '$contact','$education','$answer','$email','$pass', '$photourl')";

                                                   // 

                if(mysql_query($forquery)){
                   echo 'you have successfully registered'; 

                }
                else
                 echo 'wrong!!!!';

                // Set up regular expression strings to evaluate the value of email variable against
        $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
        // Run the preg_match() function on regex against the email address
        if (preg_match($regex, $email)) {
           echo $email . " is a valid email. We can accept it.";
        }
        else { 
         echo $email . " is an invalid email. Please try again.";
        } 

               mysql_close($con); 

                //echo "hlw";

             }
///*/
//print("<script>window.location.replace('index.php');<//script>");  

?>

Original comment by angarkh...@gmail.com on 17 Jun 2012 at 9:08