Jump to content

PHP Beginner


bambo123

Recommended Posts

hey guys, I am very new to PHP and wanted to create a simple form script. Somehow it doesnt work... can you help me? Help is highly appreciated!!

 

here is the code:

 

<?php



$admin= 'name@email.com';



//     1. Message to the admin



$subject1= 'You have one new subscription';


$message1.= 'Email:    '.$email."\n\n";

  $message1.= 'Name:    '.$name."\n\n";


// Sending mail



mail($admin, $subject1, $message1, "From: $email");




header('Location: http://www.youtube.com');


?>

Link to comment
Share on other sites

1 question: I dont receive an email at all, even though I am redirected to youtube.com...

 

2 question: I have a normal form and if someone clicks on the submit button this php script is started. Isn't that possible?

Link to comment
Share on other sites

1 question: I dont receive an email at all, even though I am redirected to youtube.com...

 

2 question: I have a normal form and if someone clicks on the submit button this php script is started. Isn't that possible?

 

mail is dependent on the local mail transfer agent program on the operating system.  What OS are you running this on?

 

You get variables from a form that uses the POST method in the $_POST[] superglobal.  Read those variable values in at the top of your script.

Link to comment
Share on other sites

This is the code of my form:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form method="POST" action="action.php" id="form" " value="0" type="hidden">
Email:</label><input class="inputtext" id="email" name="email" value="" onkeypress="formchange()" type="text"></div><div class="form_row clearfix "><label for="pass" id="label_pass" class="login_form_label">Name:</label><input class="inputpassword" id="name" name="name" value="" type="name"></div>
<label class="uiButton uiButtonConfirm uiButtonLarge" for="u261249_1"><input value="Send" name="login" onclick="" id="u261249_1" type="submit"></label> 
</strong></div>
</form>
</body>
</html>

 

For testing reasons I wanted to run my page on a server of this free webhost:

http://members.000webhost.com/login.php

 

 

Link to comment
Share on other sites

Not sure if this solves the issues, but before concatenating a var you need to first define it. This wont work:

$message1 .= 'Email:    '.$email."\n\n";
$message1 .= 'Name:    '.$name."\n\n";

 

It has to be:

Not sure if this solves the issues, but before concatenating a var you need to first define it. This wont work:

$message1 = 'Email:    '.$email."\n\n";
$message1 .= 'Name:    '.$name."\n\n";

 

Link to comment
Share on other sites

Most web host require your email to be sent from an account that exist on their servers.  So you would need to go to your cPanel, and make an email account.  Then hard code that account as the "From: $email" inside the email function.

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.