Jump to content

Form Acting Up


Xtremer360

Recommended Posts

I for the life of me can not see why this isn't working all basically copied the exact file from another one but made some changes maybe I screwed somethign up along the way. Its showing both messages when the form is opened and it obviously shouldn't be for one and then when I try and test the script it shows me this in the url: http://defiantwrestling.net/efedmanager/index?username=testing&password=testing&firstname=testing&lastname=test&email=testing%40yahoo.com&status=1&admin=Yes&submithandler=Submit+Handler#

 

With how i have all my pages linked and what not I have everything with a pound sign inside the links and what not so I'm now sure why its showing that.

 

<?php
   
// Include the database page
include ('../inc/dbconfig.php');
    
?>
<script type="text/javascript">
    $(document).ready(function() {
    $('div.message-error').hide();
    $('div.message-success').hide();
    $("input.submit").click(function() {
        $('div.message-error').hide();
        var username = $("input#username").val();
  		if (username == "") {
        $("div.message-error").show();
        $("input#username").focus();
        return false;
      } 
      var password = $("input#password").val();
  		if (password == "") {
        $("div.message-error").show();
        $("input#password").focus();
        return false;
      } 
      var firstname = $("input#firstname").val();
  		if (firstname == "") {
        $("div.message-error").show();
        $("input#firstname").focus();
        return false;
      } 
      var lastname = $("input#lastname").val();
  		if (lastname == "") {
        $("div.message-error").show();
        $("input#lastname").focus();
        return false;
      } 
      var email = $("input#email").val();
  		if (email == "") {
        $("div.message-error").show();
        $("input#email").focus();
        return false;
      } 
      var status = $("select#status").val();
  		if (status == "") {
        $("div.message-error").show();
        $("select#status").focus();
        return false;
      } 
      var admin = $("select#admin").val();
  		if (admin == "") {
        $("div.message-error").show();
        $("select#admin").focus();
        return false;
      } 
        var dataString = 'username=' + username  + '&password=' + password + '&firstname=' + firstname + '&lastname=' + lastname + '&email=' + email + '&status=' + status + '&admin=' + admin + '&submithandler=True';
        $.ajax({
        type: "POST",
        url: "processes/handler.php",
        data: dataString,
        success: function() {
        $('div.message-error').hide();
        $("div.message-success").html("<h6>Operation successful</h6><p>Handler " + firstname + lastname " saved successfully.</p>");
        $("div.message-success").show().delay(10000).hide("slow");
        $(':input','#handlerform')
        .not(':submit')
        .val('')
        return true;
    }
  });
  return false;    
    });
  });
  
</script>
<!-- Form -->
<form action="#" id="handlerform" >
<fieldset>
	<legend>Add New Handler</legend>

	<div class="field required">
		<label for="username">User Name</label>
		<input type="text" class="text" name="username" id="username" title="User Name"/>
		<span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
		<label for="password">Password</label>
		<input type="password" class="text" name="password" id="password" title="Password"/>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
		<label for="firstname">First Name</label>
		<input type="text" class="text" name="firstname" id="firstname" title="First Name"/>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
		<label for="lastname">Last Name</label>
		<input type="text" class="text" name="lastname" id="lastname" title="Last Name"/>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
		<label for="email">Email</label>
		<input type="text" class="text" name="email" id="email" title="Email"/>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
		<label for="status">Status</label>
            <select class="dropdown" name="status" id="status" title="Status">
            <option value="0">- Select -</option>
            <?php
            $query = 'SELECT id, statusname FROM statuses';
            $result = mysqli_query ( $dbc, $query ); // Run The Query
            while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { 
                print "<option value=\"".$row['id']."\">".$row['statusname']."</option>\r";
            }
            ?>
            </select>
		<span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
		<label for="admin">Administrator</label>
            <select class="dropdown" name="admin" id="admin" title="Administrator">
            <option value="0">- Select -</option>
            <?php
                $administrator = array('Yes', 'No');
                foreach($administrator as $admin):
            ?>        
            <option value="<?php echo $admin; ?>"><?php echo $admin; ?></option>
         
         <?php endforeach; ?>
            </select>
		<span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <input type="submit" class="submit" name="submithandler" id="submithandler" title="Submit Handler" value="Submit Handler"/>
</fieldset>
</form>
<!-- /Form -->

<!-- Messages -->
<div class="message message-error">
    <h6>Required field missing</h6>
    <p>Please fill in all required fields. </p>
</div>

<div class="message message-success">
    <h6>Operation succesful</h6>
    <p>Handler was added to the database.</p>
</div>
<!-- /Messages -->

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.