Need help urgently, Came across this code and i am now using it but now i need to validate data

0 Samuel sendi · October 22, 2015
<div class="block-content collapse in">
                         <div class="alert alert-success"><i class="icon-info-sign"></i> Fill in required details</div>
                            
                            
                            
                            
<form class="form-horizontal" method="post">
                                <div class="control-group">
<label class="control-label" for="inputPassword">First Name: </label>
<div class="controls">
<input type="text" class="span8" name="first_name" id="inputPassword" placeholder="First Name" required>
</div>
</div>
                               
                                <div class="control-group">
<label class="control-label" for="inputPassword"> Last Name: </label>
<div class="controls">
<input type="text" class="span8" name="last_name" id="inputPassword" placeholder="Last Name" required>
</div>
</div>
                                
                                 <div class="control-group">
                                <label class="control-label" for="inputEmail">Sex: </label>
                               <div class="controls">
                             <select name="sex_id" class="chzn-select"  required/>
                               <option>--select gender--</option> 
                                                <option>Male</option>
                                     <option >Female</option>
                                
                              </select>
                                    </div>
                                   </div>
                                
                                
                                <div class="control-group">
<label class="control-label" for="inputPassword">National ID: </label>
<div class="controls">
<input type="text" class="span8" name="nid" id="inputPassword" placeholder="National ID Number" required>
</div>
</div>

<div class="control-group">
<label class="control-label" for="inputPassword">Contact: </label>
<div class="controls">
<input type="text" class="span8" name="contact" id="inputPassword" placeholder="07XX-XXXX / +2567XX-XXXX" required>
</div>
</div>

<div class="control-group">
<label class="control-label" for="inputPassword">Email: </label>
<div class="controls">
<input type="text" class="span8" name="email" id="inputPassword" placeholder="example@watotochurch.com" required>
</div>
</div>
                                
                                <div class="control-group">
<label class="control-label" for="inputPassword">Date of Birth: </label>
<div class="controls">
<input type="text" class="span8" name="dob" id="inputPassword" placeholder="YYYY-MM-DD" required>
</div>
</div>
                                
                                
<div class="control-group">
<label class="control-label" for="inputPassword">Cell: </label>
<div class="controls">
<input type="text" class="span8" name="cell" id="inputPassword" placeholder="Home Cell" required>
</div>
</div>

<div id="hide">
<div class="control-group">
<label class="control-label" for="inputPassword"  placeholder="Vol Status" >Volunteer Status</label>
<div class="controls">
<select name="vol_status"  required>
<option>New</option>
</select>
</div>
</div>
</div>
                                
                                   <div class="control-group">
                                <label class="control-label" for="inputEmail">Celebration Point</label>
                               <div class="controls">
                             <select name="dev_id" class="chzn-select"  required/>
                                <option></option>
                                    <?php $device_name=mysql_query("select * from device_name")or die(mysql_error()); 
                                    while ($row=mysql_fetch_array($device_name)){
?>
                                <option value="<?php echo $row['dev_id']; ?>&nbspName&nbsp<?php echo $row['dev_name']; ?>"><?php echo $row['dev_name']; ?></option>
                                <?php } ?>
                              </select>
                                    </div>
                                   </div>

<div class="control-group">
<label class="control-label" for="inputPassword">Address: </label>
<div class="controls">
<textarea name="address" id="ckeditor_full"></textarea>
</div>
</div>
                                    
                                    
                                        <div class="control-group">
                                <label class="control-label" for="inputEmail">Work Status: </label>
                               <div class="controls">
                             <select name="work_status" class="chzn-select"  required/>
                               <option>--select type of employment--</option> 
                                                <option>Employed</option>
                                                <option >Un-Employed</option>
                               <option>Part-Time</option>
                                                <option >Vacation</option>
                                                <option>Student</option>
                                                <option >Retired</option>
                              </select>
                                    </div>
                                   </div>
                            
                            
                                        <div class="control-group">
<label class="control-label" for="inputPassword">Proffession: </label>
<div class="controls">
<input type="text" class="span8" name="proffession" id="inputPassword" placeholder="*If Employed, What do you do?">
</div>
</div>
                            
                                        <div class="control-group">
<label class="control-label" for="inputPassword">Employer: </label>
<div class="controls">
<input type="text" class="span8" name="employer" id="inputPassword" placeholder="Place of Work">
</div>
</div>
                            
                                        <div class="control-group">
<label class="control-label" for="inputPassword">School: </label>
<div class="controls">
<input type="text" class="span8" name="school" id="inputPassword" placeholder="*If Student, Wchich School?">
</div>
</div>
                                        

<div class="control-group">
<div class="controls">
<button name="save" id="save" name="singlebutton" data-placement="right" title="Click here to Save your new data." class="btn btn-primary"><i class="icon-save"></i> Save</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#save').tooltip('show');
$('#save').tooltip('hide');
});
</script>
</form>
<?php
if (isset($_POST['save'])){
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$dev_id = $_POST['dev_id'];
$address = $_POST['address'];
$nid = $_POST['nid'];
$contact = $_POST['contact'];
$cell = $_POST['cell'];
$email = $_POST['email'];
$dob = $_POST['dob'];
$proffession = $_POST['proffession'];
$employer = $_POST['employer'];
$school = $_POST['school'];
$sex_id = $_POST['sex_id'];
$work_status = $_POST['work_status'];
$vol_status = $_POST['vol_status'];



$query = mysql_query("select * from stdevice where nid = '$nid' ")or die(mysql_error());
$count = mysql_num_rows($query);

if ($count > 0){ 

    
    
    
    
?>
                            
<script>
alert('Volunteer Already Exist');
window.location = "add_device.php";
</script>
                            
                            
<?php
}else{
mysql_query("insert into stdevice (dev_id,address,nid,contact,cell,vol_status,last_name,first_name,email,dob,proffession,employer,school,sex_id,work_status) values('$dev_id','$address','$nid','$contact','$cell','$vol_status','$last_name','$first_name','$email','$dob','$proffession','$employer','$school','$sex_id','$work_status')")or die(mysql_error());
mysql_query("insert into activity_log (date,username,action) values(NOW(),'$admin_username','Add device Detail id $dev_id')")or die(mysql_error());
?>
<script>
window.location = "device_stocks.php";
$.jGrowl("Volunteer Successfully added", { header: 'Volunteer add' });
</script>
<?php
}
}
?>

                           </div>
                       </div>
                       <!-- /block -->
                   </div>
               </div>
            </div>
<?php include('footer.php'); ?>
        </div>

Post a Reply

Replies

Oldest  Newest  Rating
0 Arira joseph · October 22, 2015
What do you want done
  • 1

PHP

106,979 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators