Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2010-05-05, 09:14 PM   #1
A.J. Angel
And Lord, we are especially thankful for nuclear power, the cleanest, safest
energy source there is. Except for solar, which is just a pipe dream
 
Join Date: Sep 2008
Posts: 229
Help with PHP submit form

Hello, I have a problem that I think any experienced PHP coders may solve quickly and easily.

I have found a working contact/submit form tutorial that provided coding which I modified to the following to suit my purpose, in this case, let models request their addition to my site by submitting their informations:

PHP Code:
<?php
/* Check all form inputs using check_input function */
$name check_input($_POST['name'], "Please enter your name.");
$birthname check_input($_POST['birthname']);
$alias check_input($_POST['alias']);
$dateofbirth check_input($_POST['dateofbirth']);
$placeofbirth check_input($_POST['placeofbirth']);
$ethnicity check_input($_POST['ethnicity']);
$height check_input($_POST['height']);
$weight check_input($_POST['weight']);
$haircolor check_input($_POST['haircolor']);
$eyecolor check_input($_POST['eyecolor']);
$measurements check_input($_POST['measurements']);
$piercings check_input($_POST['piercings']);
$tattoos check_input($_POST['tattoos']);
$officialsite check_input($_POST['officialsite']);
$store check_input($_POST['store']);
$auction check_input($_POST['auction']);
$blog check_input($_POST['blog']);
$messageboard check_input($_POST['messageboard']);
$facebook check_input($_POST['facebook']);
$myspace check_input($_POST['myspace']);
$twitter check_input($_POST['twitter']);
$email check_input($_POST['email'], "Please enter your e-mail address.");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/"$email))
{
    
show_error("Please enter a valid e-mail address.");
}

/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i"$officialsite))
{
    
$officialsite '';
}

/* Let's prepare the message for the e-mail */
$message "Hello,

A new model has requested to be added on Exquisite Angelz.

Name: 
$name
Birth Name: 
$birthname
Alias(es): 
$alias
Date Of Birth: 
$dateofbirth
Place Of Birth: 
$placeofbirth
Ethnicity: 
$ethnicity
Height: 
$height
Weight: 
$weight
Hair Color: 
$haircolor
Eye Color: 
$eyecolor
Measurements: 
$measurements
Piercing(s): 
$piercings
Tattoo(s): 
$tattoos

Official Site(s): 
$officialsite
Store(s): 
$store
Auction(s): 
$auction
Blog(s): 
$blog
Message Board(s): 
$messageboard
Facebook: 
$facebook
MySpace: 
$myspace
Twitter: 
$twitter

E-Mail Address: 
$email

Kind Regards,
A.J. Angel

Exquisite Angelz
http://www.exquisiteangelz.com/
webmaster@exquisiteangelz.com
"
;

/* Send the message using mail() function */
mail("webmaster@exquisiteangelz.com""New Model: $name""$message");

/* Redirect visitor to the thank you page */
header('Location: index-beta.php');
exit();

/* Functions we used */
function check_input($data$problem='')
{
    
$data trim($data);
    
$data stripslashes($data);
    
$data htmlspecialchars($data);
    if (
$problem && strlen($data) == 0)
    {
        
show_error($problem);
    }
    return 
$data;
}

function 
show_error($myError)
{
?>
    <html>
    <body>

    <b>Please correct the following error:</b><br />
    <?php echo $myError?>

    </body>
    </html>
<?php
exit();
}
?>
Although the script works, unfortunately for me, the errors are not displayed on the same page as the form. I tried to replace the HTML code included with my own HTML code for the contact form page but it doesn't work because the errors would be automatically displayed anyway.

Therefore, I wish to ask if there is someone good with PHP who would be kind enough to provide me the correct code to have a script page where a model can submit her informations and if there are errors, the errors are displayed on the same page similarly to what occurs on linklist scripts submission forms. Thank you!!!

If it is of any help, here is the form for models to submit their informations:

Code:
<form action="submit.php" method="post">
<div id="models">
<img src="http://img.exquisiteangelz.com/models.png" width="1200" height="50" border="0">
<table align="center" cellspacing="0" cellpadding="0">
<tr><td class="profile" colspan="2">Please provide us with informations about yourself.</td></tr>
<tr><td class="data">Name:</td><td class="information"><input type="text" name="name" size="50"/><div>(required)</div></td></tr>
<tr><td class="data">Birth Name:</td><td class="information"><input type="text" name="birthname" size="50"/></td></tr>
<tr><td class="data">Alias(es):</td><td class="information"><input type="text" name="alias" size="50"/></td></tr>
<tr><td class="data">Date Of Birth:</td><td class="information"><input type="text" name="dateofbirth" size="50"/></td></tr>
<tr><td class="data">Place Of Birth:</td><td class="information"><input type="text" name="placeofbirth" size="50"/></td></tr>
<tr><td class="data">Ethnicity:</td><td class="information"><input type="text" name="ethnicity" size="50"/></td></tr>
<tr><td class="data">Height:</td><td class="information"><input type="text" name="height" size="50"/></td></tr>
<tr><td class="data">Weight:</td><td class="information"><input type="text" name="weight" size="50"/></td></tr>
<tr><td class="data">Hair Color:</td><td class="information"><input type="text" name="haircolor" size="50"/></td></tr>
<tr><td class="data">Eye Color:</td><td class="information"><input type="text" name="eyecolor" size="50"/></td></tr>
<tr><td class="data">Measurements:</td><td class="information"><input type="text" name="measurements" size="50"/></td></tr>
<tr><td class="data">Piercing(s):</td><td class="information"><input type="text" name="piercings" size="50"/></td></tr>
<tr><td class="data">Tattoo(s):</td><td class="information"><input type="text" name="tattoos" size="50"/></td></tr>
<tr><td class="links" colspan="2">Please provide us with your official links.</td></tr>
<tr><td class="data">Official Site(s):</td><td class="information"><input type="text" name="officialsite" size="50"/></td></tr>
<tr><td class="data">Store(s):</td><td class="information"><input type="text" name="store" size="50"/></td></tr>
<tr><td class="data">Auction(s)</td><td class="information"><input type="text" name="auction" size="50"/></td></tr>
<tr><td class="data">Blog(s)</td><td class="information"><input type="text" name="blog" size="50"/></td></tr>
<tr><td class="data">Message Board(s):</td><td class="information"><input type="text" name="messageboard" size="50"/></td></tr>
<tr><td class="data">Facebook:</td><td class="information"><input type="text" name="facebook" size="50"/></td></tr>
<tr><td class="data">MySpace:</td><td class="information"><input type="text" name="myspace" size="50"/></td></tr>
<tr><td class="data">Twitter:</td><td class="information"><input type="text" name="twitter" size="50"/></td></tr>
<tr><td class="email" colspan="2">Please provide us with an e-mail address to contact you.</td></tr>
<tr><td class="data">E-Mail Address:</td><td class="information"><input type="text" name="email" size="50"/><div>(we shall not disclose or spam your e-mail address)</div></td></tr>
</table>
<input type="submit" value="Submit">
</div>
</form>
A.J. Angel is offline   Reply With Quote
Old 2010-05-06, 03:00 PM   #2
A.J. Angel
And Lord, we are especially thankful for nuclear power, the cleanest, safest
energy source there is. Except for solar, which is just a pipe dream
 
Join Date: Sep 2008
Posts: 229
Issue solved. Thanks for looking.
A.J. Angel is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:02 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc