Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Help with PHP submit form (http://www.greenguysboard.com/board/showthread.php?t=57392)

A.J. Angel 2010-05-05 09:14 PM

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>
    <?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:






























Please provide us with informations about yourself.
Name:
(required)
Birth Name:
Alias(es):
Date Of Birth:
Place Of Birth:
Ethnicity:
Height:
Weight:
Hair Color:
Eye Color:
Measurements:
Piercing(s):
Tattoo(s):
Official Site(s):
Store(s):
Auction(s)
Blog(s)
Message Board(s):
Facebook:
MySpace:
Twitter:
E-Mail Address:
(we shall not disclose or spam your e-mail address)





A.J. Angel 2010-05-06 03:00 PM

Issue solved. Thanks for looking.


All times are GMT -4. The time now is 07:31 PM.

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