Jump to content

PHP Form with captcha formatting issues


doublejz

Recommended Posts

Still learning PHP but about ready give up on this task. I'm trying to take an existing contact form for a user and add a simple captcha check box to it. However, the only way I can get it to work is by changing pretty much all the code around but then I lose the style/formatting.

No captcha

            <form action="index.php" id="contact-form" method="post">
            <ol class="forms">
                    <li>
                        <label for="name">Name:</label>
                        <?php if($nameError != '') { ?>
                            <span class="error"><?=$nameError;?></span> 
                        <?php } ?>                
                        <input type="text" name="name" id="name" value="<?php if(isset($_POST['name'])) echo $_POST['name'];?>" class="required" />
                    </li>
                    <li>
                        <label for="email">Email:</label>
                        <?php if($emailError != '') { ?>
                            <span class="error"><?=$emailError;?></span>
                        <?php } ?>                
                        <input type="text" name="email" id="email" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" class="required" />
                    </li>
                        <li class="textarea"><label for="textarea">Message:</label>
                        <?php if($textareaError != '') { ?>
                            <span class="error"><?=$textareaError;?></span> 
                        <?php } ?>            
                        <textarea name="textarea" id="textarea" rows="10" cols="30" class="required"><?php if(isset($_POST['textarea'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['textarea']); } else { echo $_POST['textarea']; } } ?></textarea>
                    </li>
                    </ol>
                    <ol class="button-group">
                    <li>
                        <div>
                            <input type="hidden" name="submitted" id="submitted" value="true">
                            <input type="submit" value="Submit" class="submit">
                        </div>
                    </li>
                </ol>
            </form>

1015910587_indexnocaptcha.png.95479775c4a8b82d75ead280d2ac51cd.png

 

With captcha

			<form action="index2.php" id="contact-form" method="post>
			<form id="frmContact" action="" method="POST" novalidate>
			<div class="theme-default">Name:</div>
			<div class="field">
				<input type="text" id="name" name="name" placeholder="enter your name here" title="Please enter your name" class="required">
			</div>
			<div class="label">Email:</div>
			<div class="field">			
				<input type="text" id="email" name="email" placeholder="enter your email address here" title="Please enter your email address" class="required email">
			</div>
			<div class="label">Comments:</div>
			<div class="field">			
				<textarea id="comment-content" name="content" placeholder="enter your comments here"></textarea>			
			</div>
			<div class="g-recaptcha" data-sitekey="<?php echo SITE_KEY; ?>"></div>			
			<div id="mail-status"></div>			
			<button type="Submit" id="send-message" style="clear:both;">Send Message</button>
		</form>
		<div id="loader-icon" style="display:none;"><img src="img/loader.gif" /></div>
		</div>		
			</form>

 

1580089446_indexwithcaptcha.png.28478aeac2910ac89287a2ad170b3b3b.png

 

Its probably something super simple as I'm still self learning PHP on the side but its driving me crazy trying to figure out how to keep the formatting/class/style/etc.

 

TIA

Link to comment
Share on other sites

No idea what your css looks like, but the second snippet is a form within a form, and all the fields are inside the inner form. Depending on how your element selectors are set up, that could cause a problem. Either way, if I'm not mistaken it'll almost certainly effect your form function.

Link to comment
Share on other sites

10 hours ago, mac_gyver said:

how would this help anyone to help you with any problem concerning the incorrect operation of the recaptcha coded page?

Sorry forget the second link.

Current non-recaptcha
http://www.decal-kreations.com/
 

Recaptcha - Works but that loses all formatting/style
http://decal-kreations.com/index2.php


I also just added this one
Recaptcha - with just the div class="g-recaptcha" data-sitekey="<?php echo SITE_KEY; ?>"></div> added but seems to break everything
http://decal-kreations.com/index3.php

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.