create_account.php

<?php

include('includes/koneksi.php');

    $nama = isset($_POST['nama']) ? $_POST['nama'] : '';  
    $institusi = isset($_POST['institusi']) ? $_POST['institusi'] : '';  
    $alamat = isset($_POST['alamat']) ? $_POST['alamat'] : '';  
    $email = isset($_POST['email']) ? $_POST['email'] : ''; 
    $no_telp = isset($_POST['no_telp']) ? $_POST['no_telp'] : '';
    $confirmation = isset($_POST['confirmation']) ? $_POST['confirmation'] : '';


    //Simpan berita 
/*  if (isset($_POST['submit'])){       

        $sqlstr = "INSERT INTO `registrasi`(nama, institusi, alamat, email, no_telp) VALUES('".$nama."','".$institusi."','".$alamat."','".$email."','".$no_telp."')";


        $result = mysql_query($sqlstr) or die(mysql_error());

        //Jika mode edit, maka tidak akan dikirimkan konfirmasi kepada subscriber
        //if (empty($_REQUEST['id']))   kirimEmail($idKategori, $judul, $news);
        $confirmation = ($result) ? "Data telah tersimpan." : "Gagal menyimpan data.";  
    }
*/  

?>

<?php 

// PHP Mailer 

require '/phpmailer/PHPMailerAutoload.php';
 //memanggil library php mailernya


function smtpmailer($to, $from, $from_name, $subject, $body) {

global $error;

$mail = new PHPMailer();

//$mail->AuthType = 'NTLM';

$mail->IsSMTP();

//$mail->SMTPDebug = 0;  // untuk memunculkan pesan error /debug di layar

$mail->SMTPAuth = true;  // authentifikasi smtp enable atau disable

$mail->SMTPSecure = "";//‘ssl atau di kosongkas jika none’; // secure transfer membutuhkan authentifikasi dari mail server

$mail->Host ='ssl://smtp.gmail.com:465;tls://smtp.gmail.com:587'; // masukkan nama host email “diawal ssl://”

$mail->Port = 587; //port secure ssl email

$mail->Username = "squprime@gmail.com"; //username email

$mail->Password = "squprime2014"; //password email

$mail->SetFrom($from, $from_name);

$mail->Subject = $subject;

$mail->Body = $body;

$mail->AddAddress($to);

if(!$mail->Send()) {

$error = "Mail error: ".$mail->ErrorInfo;

return false;

} else {

$error = "Message sent!";

return true;

}

}

    /*
    $result = mysql_query("SELECT * FROM student ORDER BY student_id DESC") or die(mysql_error());
    $data = mysql_fetch_array($result);
    */

// write program to send email to the recorded email address

    /*
    $name = $data['stu_fname'];
    $email = $data['stu_email'];
    $phone = $data['stu_telp'];
    $message = "Dear Admin,"."\r\r".
    "There is a new user registration :"."\r\r";
    */

    $nama = isset($_POST['nama']) ? $_POST['nama'] : '';  
    $institusi = isset($_POST['institusi']) ? $_POST['institusi'] : '';  
    $alamat = isset($_POST['alamat']) ? $_POST['alamat'] : '';  
    $email = isset($_POST['email']) ? $_POST['email'] : ''; 
    $no_telp = isset($_POST['no_telp']) ? $_POST['no_telp'] : '';


    $nama = $_POST['nama'];
    $institusi = $_POST['institusi'];
    $alamat = $_POST['alamat'];
    $email = $_POST['email'];
    $no_telp = $_POST['no_telp'];
    $message = "Dear Admin,"."\r\r".
    "There is a new user registration :"."\r\r";

    /*if (@$_POST['submit']) {*/
    if ($nama&&$institusi&&$alamat&&$email&&$no_telp) {
    if (is_numeric($phone)) {

    $body = $message.
    "Nama: ".$nama.
    "\rInstitusi: ".$institusi.
    "\rAlamat: ".$alamat.
    "\remail: ".$email.
    "\rno_telp: ".$no_telp. 
    "\n\nPlease contact the person soon.";

    //mail("squprime@gmail.com", "squprime@gmail.com", "Davy", "Request Trial", $body); 

    smtpmailer("squprime@gmail.com", "squprime@gmail.com", "squprime.com", "Request Trial", $body); 


    echo "Your message has been sent, we will get back to your shortly.";
    $name = trim("");
    $email = trim("");
    $phone = trim("");
    $message = trim("");
    }
    else
    echo "There should only be numbers in your phone number.";
    } 
    else
    echo "Please fill in <b>all</b> the fields!";


?>  





        <div id="contentForm">

            <?php
            header('Content-Type: text/html; charset=utf-8');

            if(isset($_POST['email'])) {


                // EDIT THE 2 LINES BELOW AS REQUIRED

                //$email_to = "cs@squprime.com";
                $email_to = "squprime@gmail.com";

                $email_subject = "SquPrime Free trial request!";


                $first_name = $_POST['first_name']; // required 
                $email_from = $_POST['email']; // required
                $phone = $_POST['phone']; // required

                $email_message = "Form details below.\n\n";


                function clean_string($string) {
                    $bad = array("content-type","bcc:","to:","cc:","href");
                    return str_replace($bad,"",$string);
                }


                $email_message .= "Name: ".clean_string($first_name)."\n";
                $email_message .= "Email Address: ".clean_string($email_from)."\n";
                $email_message .= "Phone Number: ".clean_string($phone)."\n";


                // create email headers

                $headers = 'From: '.$email_from."\r\n".

                'Reply-To: '.$email_from."\r\n" .

                'X-Mailer: PHP/' . phpversion();

                //@mail($email_to, $email_subject, $email_message, $headers);

                //$ok = @mail($email_to, $email_subject, $email_message, $headers);

                $ok = mail("squprime@gmail.com", "Subject", "This is the email message", "From me");

                if($ok){ echo "successfully sent message"; } else { echo "failed to send message"; }
                ?>

                <!-- Message sent! (change the text below as you wish)-->
                <div class="container">
                    <div class="row">
                        <div class="col-sm-6 col-sm-offset-3">
                            <div id="form_response" class="text-center">
                                <img class="img-responsive" src="img/thumbs/mail_sent.png" alt="image" />
                                <h1>Your request is sent!</h1>
                                <p>Thank you <b><?=$first_name;?></b>, our advisor will contact you within 24 hours!</p>
                                <a class="btn btn-theme btn-lg" href="index.php">Back To The Site</a>
                            </div>
                        </div>   
                    </div>                   
                </div>
                 <!--End Message Sent-->

                <?php

                }

                ?>

<center>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">
<table border="1" style="width: 10%;">
<tr>USER REGISTRATION</tr>
<tr></tr>
<tr>
<td>Nama :</td>
<td><input type="text" class="form" name="nama"></td>
</tr><br>
<tr>
<td>Institusi :</td>
<td><input type="text" class="form" name="institusi"></td>
</tr><br>
<tr><td>Alamat :</td>
<td><input type="text" class="form" name="alamat"></td>
</tr><br>
<tr><td>Email :</td>
<td><input type="text" class="form" name="email"></td>
</tr><br>
<tr><td>No_telp :</td>
<td><input type="text" class="form" name="no_telp"></td>
</tr><br>
</table><br>
<input type="submit" name="submit" value="ENTER"></input>
<!-- class="login"  -->
</form>
</center>

Notice: Undefined index: nama in C:\xampp\htdocs\portal\create_account.php on line 154

Notice: Undefined index: institusi in C:\xampp\htdocs\portal\create_account.php on line 155

Notice: Undefined index: alamat in C:\xampp\htdocs\portal\create_account.php on line 156

Notice: Undefined index: email in C:\xampp\htdocs\portal\create_account.php on line 157

Notice: Undefined index: no_telp in C:\xampp\htdocs\portal\create_account.php on line 158
Please fill in all the fields!

Line 154 - 158:

$nama = $_POST['nama'];
$institusi = $_POST['institusi'];
$alamat = $_POST['alamat'];
$email = $_POST['email'];
$no_telp = $_POST['no_telp'];

How to fix the error?

You do not check if something is actually posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.