Results 1 to 2 of 2

Thread: Forms dont get submitted

  1. #1
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Forms dont get submitted

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem:

    Whenever i want to submit a form, it wont get submitted and redirects me to the homepage instead. Please help me. The code is(form):

    Code:
    <?php
    	require_once( "../commandcenter/_inc/glob.php" );
    ?>  
    <div id="maincont">
      <div id="mainconttop"></div>
      <div id="maincontmid">
      <div id="contheadpink">Request Line</div>
       <?php
    				
    				if( $_POST['submit'] ) {
    					
    					try {
    					
    						$habbo   = $core->clean( $_POST['habbo'] );
    						$type    = $core->clean( $_POST['type'] );
    						$dj      = $core->clean( $_POST['dj'] );
    						$request = $core->clean( $_POST['request'] );
    						$ip      = $_SERVER['REMOTE_ADDR'];
    						$time    = time();
    	
    						if( !$habbo or !$type or !$dj or !$request or !is_numeric( $dj ) or !is_numeric( $type ) ) {
    	
    							throw new Exception( "All fields are required" );
    	
    						}
    						else {
    						
    							$db->query( "INSERT INTO requests VALUES (NULL, '{$type}', '{$dj}', '{$habbo}', '{$request}', '{$time}', '{$ip}');" );
    
    							echo "<div class=\"good\">";
    							echo "<strong>Success</strong>";
    							echo "<br />";
    							echo "Request sent!";
    							echo "</div>";
    
    						}
    					
    					}
    					catch( Exception $e ) {
    					
    						echo "<div class=\"bad\">";
    						echo "<strong>Error</strong>";
    						echo "<br />";
    						echo $e->getMessage();
    						echo "</div>";
    					
    					}
    					
    				}
    				
    			?>
    
    			<form action="" method="post" id="ajaxmenu">
    			
    				<label for="habbo">Habbo name:</label>
    				<input type="text" name="habbo" id="habbo" maxlength="255" />
    				
    				<br /><br />
    				
    				<label for="type">Message type:</label>
    				<select name="type" id="type">
    				
    					<?php
    						
    						$query = $db->query( "SELECT * FROM request_types" );
    						
    						while( $array = $db->assoc( $query ) ) {
    						
    					?>
    					
    					<option value="<?php echo $array['id']; ?>">
    						<?php echo $array['name']; ?>
    					</option>
    					
    					
    					<?php
    						
    						}
    						
    					?>
    				
    				</select>
    			
    				<br /><br />
    			
    				<label for="dj">DJ:</label>
    				<select name="dj" id="dj">
    
    					<?php
    
    
    
    						$query2 = $db->query( "SELECT * FROM users" );
    
    						while( $array2 = $db->assoc( $query2 ) ) {
    
    					?>
    
    					<option<?php if( preg_match( "/{$array2['username']}/", $info['streamtitle'] ) ) { ?> selected="selected"<?php } ?> value="<?php echo $array2['id']; ?>">
    						DJ <?php echo $array2['username']; ?>
    					</option>
    
    
    					<?php
    
    						}
    
    					?>
    
    				</select>
    				
    				<br /><br />
    				
    				<label for="request">Request:</label>
    				<textarea name="request" id="request" rows="5"></textarea>
    				
    				<br /><br />
    				
    				<input onClick="ajaxcombo('ajaxmenu', 'sitecont')" class="button" type="button" name="submit" value="Request" />
    				
    			</form>
      </div>
      <div id="maincontbot"></div>
    </div>

  2. #2
    Join Date
    Jan 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by JianTing View Post
    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem:

    Whenever i want to submit a form, it wont get submitted and redirects me to the homepage instead. Please help me. The code is(form):

    Code:
    <?php
    	require_once( "../commandcenter/_inc/glob.php" );
    ?>  
    <div id="maincont">
      <div id="mainconttop"></div>
      <div id="maincontmid">
      <div id="contheadpink">Request Line</div>
       <?php
    				
    				if( $_POST['submit'] ) {
    					
    					try {
    					
    						$habbo   = $core->clean( $_POST['habbo'] );
    						$type    = $core->clean( $_POST['type'] );
    						$dj      = $core->clean( $_POST['dj'] );
    						$request = $core->clean( $_POST['request'] );
    						$ip      = $_SERVER['REMOTE_ADDR'];
    						$time    = time();
    	
    						if( !$habbo or !$type or !$dj or !$request or !is_numeric( $dj ) or !is_numeric( $type ) ) {
    	
    							throw new Exception( "All fields are required" );
    	
    						}
    						else {
    						
    							$db->query( "INSERT INTO requests VALUES (NULL, '{$type}', '{$dj}', '{$habbo}', '{$request}', '{$time}', '{$ip}');" );
    
    							echo "<div class=\"good\">";
    							echo "<strong>Success</strong>";
    							echo "<br />";
    							echo "Request sent!";
    							echo "</div>";
    
    						}
    					
    					}
    					catch( Exception $e ) {
    					
    						echo "<div class=\"bad\">";
    						echo "<strong>Error</strong>";
    						echo "<br />";
    						echo $e->getMessage();
    						echo "</div>";
    					
    					}
    					
    				}
    				
    			?>
    
    			<form action="" method="post" id="ajaxmenu">
    			
    				<label for="habbo">Habbo name:</label>
    				<input type="text" name="habbo" id="habbo" maxlength="255" />
    				
    				<br /><br />
    				
    				<label for="type">Message type:</label>
    				<select name="type" id="type">
    				
    					<?php
    						
    						$query = $db->query( "SELECT * FROM request_types" );
    						
    						while( $array = $db->assoc( $query ) ) {
    						
    					?>
    					
    					<option value="<?php echo $array['id']; ?>">
    						<?php echo $array['name']; ?>
    					</option>
    					
    					
    					<?php
    						
    						}
    						
    					?>
    				
    				</select>
    			
    				<br /><br />
    			
    				<label for="dj">DJ:</label>
    				<select name="dj" id="dj">
    
    					<?php
    
    
    
    						$query2 = $db->query( "SELECT * FROM users" );
    
    						while( $array2 = $db->assoc( $query2 ) ) {
    
    					?>
    
    					<option<?php if( preg_match( "/{$array2['username']}/", $info['streamtitle'] ) ) { ?> selected="selected"<?php } ?> value="<?php echo $array2['id']; ?>">
    						DJ <?php echo $array2['username']; ?>
    					</option>
    
    
    					<?php
    
    						}
    
    					?>
    
    				</select>
    				
    				<br /><br />
    				
    				<label for="request">Request:</label>
    				<textarea name="request" id="request" rows="5"></textarea>
    				
    				<br /><br />
    				
    				<input onClick="ajaxcombo('ajaxmenu', 'sitecont')" class="button" type="button" name="submit" value="Request" />
    				
    			</form>
      </div>
      <div id="maincontbot"></div>
    </div>
    Hello.

    I will try to help you.

    First you need to make sure your contact form has a validation.
    Please visit http://www.dynamicdrive.com/dynamici...ilvalidate.htm

    The form you are using looks very confusing
    Visit http://www.dynamicdrive.com/style/cs...y/category/C6/ where there are more forms in CSS.

    All you have to do is somehow bring the validation into a form together. But the form i use for my website is http://www.emailmeform.com/

    Hope that helps.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •