Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Php Code Needed Iii
alex1985
post Mar 2 2008, 05:17 PM
Post #1


Super Member
*********

Group: [HOSTED]
Posts: 411
Joined: 9-February 08
Member No.: 57,615



Attached File  request_book.jpg ( 34.67k ) Number of downloads: 20


Hello, everyone. I need your help again! Who might create the PHP code, the picture is above this text.

Basically, I want when the user fill in all the information in this form, it automatically was sent to my email.
And, then, the dialog box appears or on the same window, it was said that your request has been sent.

Moreover, if the user did not fill the entire information, the dialog box appears stating that you did not fill some field.

Thanks, for help. You always do that.
Go to the top of the page
 
+Quote Post
t3jem
post Mar 2 2008, 07:15 PM
Post #2


Privileged Member
*********

Group: [HOSTED]
Posts: 522
Joined: 9-February 07
Member No.: 38,519



Oh, I actually have a script like that, i'll modify it for your needs and put up shortly

CODE
<?php
$filename = 'this.php';//name of this file
$sendmail = 'yourmail@mail.com';//your email address
$frommail = 'from@mail.com';//address the mail wants to be from

$a = $_GET['a'];
$filename = $filename."?a=1";

if($a != 1)//if not yet submitted
{
echo "<form action=$filename method='post'>";
echo "Username<br><input size=32 type='text' name='username' value='guest' /><br>";
echo "Password<br><input size=32 type='password' name='password'/><br>";
echo "Title<font color='red'> (we will add \"[request_ebook]\" in the title automatically)<br><input size=100 type='text' name='title'/>required</font><br>";
echo "Author<br><input size=32 type='text' name='author'/><br>";
echo "Language<br><input type='radio' name='language' value='none' checked>None";
echo "<input type='radio' name='language' value='english'>English";
echo "<input type='radio' name='language' value='chinese'>Chinese";
echo "<br>Pages<br><input type='text' size=32 name='pages' />";
echo "<br>Publisher<br><input type='text' size=32 name='publisher' />";
echo "<br>ISBN<br><input type='text' size=32 name='isbn' />";
echo "<br>Release date<br><input type='text' size=32 name='release' />";
echo "<br>Small book cover image URL<br><input type='text' size=100 name='smallcover' />";
echo "<br>Large book cover image URL<br><input type='text' size=100 name='largecover' />";
echo "<br>Catagory/Tag<br>";
echo "<select name='category'><option value='ebook'>ebook</option></select>";//add more options, I don't know all the options you want
echo "<select name='tag'><option value='none'>none</option></select>";//add more options, I don't know all the options you want
echo "<p><input type='submit' value='Submit'/>";
echo "</form>";
}
else//otherwise do this
{
    $email = htmlentities($_POST['email']);

    $to = "quid3d@hotmail.com";
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'From: '.$frommail. "\r\n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    
    $message = 'Username: '.htmlentities($_POST['username']).'<p>Password: '.htmlentities($_POST['password']).'<p>Title: '.htmlentities($_POST['title']).'<p>Author: '.htmlentities($_POST['author']).'<p>Language: '.htmlentities($_POST['language']).'<p>Pages: '.htmlentities($_POST['pages']).'<p>Publisher: '.htmlentities($_POST['publisher']).'<p>ISBN: '.htmlentities($_POST['isbn']).'<p>Release: '.htmlentities($_POST['release']).'<p>Small cover image URL: '.htmlentities($_POST['smallcover']).'<br><img src='.htmlentities($_POST['smallcover']).'><p>Large cover image URL: '.htmlentities($_POST['largecover']).'<br><img src='.htmlentities($_POST['largecover']).'><p>Category: '.htmlentities($_POST['category']).'<p>Tag: '.htmlentities($_POST['tag']);
    echo $message . '<p>';

    if(mail($sendmail,htmlentities($_POST['title']).'[request_ebook]',$message,$headers))
    {
        echo "Your request has been sent.";
    }
    else
    {
        echo "I'm sorry, there was an error and the request was not sent.";
    }
}

?>


Alright, that should work, I wasn't able to test it because XAMPP defaults to disabling the mail function; however, trap17 has the mail function enabled if you are using trap for hosting.

Just fill in the variables at the top with the values you need.

If you have any questions about it feel free to PM me, I won't be checking up on this thread later. Hope this is what you were looking for biggrin.gif

This post has been edited by t3jem: Mar 2 2008, 08:25 PM
Go to the top of the page
 
+Quote Post
alex1985
post Mar 3 2008, 09:33 AM
Post #3


Super Member
*********

Group: [HOSTED]
Posts: 411
Joined: 9-February 08
Member No.: 57,615



Thanks. I really appreciate thus. The forum is great due to the fact that help is always obtained during the participation process.



Thanks for your useful reply. I wanna to make centered, and have some border over those datas. How can I do it? And below, the last column or field, I wanna have an introduction, that the user wrote some intro about the book. So, I need to insert a big field shaped like a big box or square.
Go to the top of the page
 
+Quote Post
t3jem
post Mar 5 2008, 02:43 AM
Post #4


Privileged Member
*********

Group: [HOSTED]
Posts: 522
Joined: 9-February 07
Member No.: 38,519



Alright, here it is. Hope this works out for you!

Again, won't check up on this thread after this post, so let em know if you need anything more.

CODE
<style type="text/css">
input{border: 1px #999999 solid;}
textarea{border: 1px #999999 solid;}
</style>

<?php
$filename = 'this.php';//name of this file
$sendmail = 'yourmail@mail.com';//your email address
$frommail = 'from@mail.com';//address the mail wants to be from

$a = $_GET['a'];
$filename = $filename."?a=1";

if($a != 1)//if not yet submitted
{
echo "<form action=$filename method='post'>";
echo "Username<br><input style='strong' size=32 type='text' name='username' value='guest' /><br>";
echo "Password<br><input size=32 type='password' name='password'/><br>";
echo "Title<font color='red'> (we will add \"[request_ebook]\" in the title automatically)<br><input size=100 type='text' name='title'/>required</font><br>";
echo "Author<br><input size=32 type='text' name='author'/><br>";
echo "Language<br><input type='radio' name='language' value='none' checked>None";
echo "<input type='radio' name='language' value='english'>English";
echo "<input type='radio' name='language' value='chinese'>Chinese";
echo "<br>Pages<br><input type='text' size=32 name='pages' />";
echo "<br>Publisher<br><input type='text' size=32 name='publisher' />";
echo "<br>ISBN<br><input type='text' size=32 name='isbn' />";
echo "<br>Release date<br><input type='text' size=32 name='release' />";
echo "<br>Small book cover image URL<br><input type='text' size=100 name='smallcover' />";
echo "<br>Large book cover image URL<br><input type='text' size=100 name='largecover' />";
echo "<br>Catagory/Tag<br>";
echo "<select name='category'><option value='ebook'>ebook</option></select>";//add more options, I don't know all the options you want
echo "<select name='tag'><option value='none'>none</option></select>";//add more options, I don't know all the options you want
echo "<br>Introduction: <font color='red'>Required! It'll be easier to find books if you give more details.<br><textarea cols=80 rows=50 name='introduction'></textarea>";
echo "<p><input type='submit' value='Submit'/>";
echo "</form>";
}
else//otherwise do this
{
    $email = htmlentities($_POST['email']);

    $to = "quid3d@hotmail.com";
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'From: '.$frommail. "\r\n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    
    $message = 'Username: '.htmlentities($_POST['username']).'<p>Password: '.htmlentities($_POST['password']).'<p>Title: '.htmlentities($_POST['title']).'<p>Author: '.htmlentities($_POST['author']).'<p>Language: '.htmlentities($_POST['language']).'<p>Pages: '.htmlentities($_POST['pages']).'<p>Publisher: '.htmlentities($_POST['publisher']).'<p>ISBN: '.htmlentities($_POST['isbn']).'<p>Release: '.htmlentities($_POST['release']).'<p>Small cover image URL: '.htmlentities($_POST['smallcover']).'<br><img src='.htmlentities($_POST['smallcover']).'><p>Large cover image URL: '.htmlentities($_POST['largecover']).'<br><img src='.htmlentities($_POST['largecover']).'><p>Category: '.htmlentities($_POST['category']).'<p>Tag: '.htmlentities($_POST['tag']).'<br>Introduction: '.htmlentities($_POST['introduction']);
    echo $message . '<p>';

    if(mail($sendmail,htmlentities($_POST['title']).'[request_ebook]',$message,$headers))
    {
        echo "Your request has been sent.";
    }
    else
    {
        echo "I'm sorry, there was an error and the request was not sent.";
    }
}

?>


This post has been edited by t3jem: Mar 5 2008, 03:33 AM
Go to the top of the page
 
+Quote Post
alex1985
post Mar 6 2008, 05:07 PM
Post #5


Super Member
*********

Group: [HOSTED]
Posts: 411
Joined: 9-February 08
Member No.: 57,615



Yep, the big box appears, where you can type the introduction but the data in that php file can be centered if I open it online?!
Go to the top of the page
 
+Quote Post
t3jem
post Mar 7 2008, 01:51 AM
Post #6


Privileged Member
*********

Group: [HOSTED]
Posts: 522
Joined: 9-February 07
Member No.: 38,519



Yes, you can make it centered using the <center> tag. I don't know how it would look centered (I don't think it'd be all that pretty), but it will work.
Go to the top of the page
 
+Quote Post
alex1985
post Mar 7 2008, 03:29 PM
Post #7


Super Member
*********

Group: [HOSTED]
Posts: 411
Joined: 9-February 08
Member No.: 57,615



So, I can use HTML tags and plug it into PHP code, it does work in this way?!

Well, I need as well to create a button callled "reset" or "clear" next to submit button. When, you pressed it, the typed information will be erased.
Go to the top of the page
 
+Quote Post
t3jem
post Mar 8 2008, 07:00 AM
Post #8


Privileged Member
*******