I have an assignment due and i might be asking for too much help so im sorry for that. I have very little knowledge about php and html. i have never ever done this in my whole entire life. So any help would be greatly appreciated. Thanks

I have to basically make 2 forms, an incident form where you enter the information and its updated to the database(im using phpmy admin provided by my college) I have made the html for both of them. My main concern is PHP. i have some of th coding setup, i can connect it to mysql but the data entered is not entered in the database. I have no clue how to fix that. Also i need help with some more things. Like ENCRYPTED PASSWORD & DATA RETRIEVAL: Authenticate the request and authorize any requests for copies to be emailed to an address entered on the form. These capabilities can be implemented using SQL select and update commands. However, in this assignment the user_password in the database must be encrypted in the database table using either the standard md5 or sha1 encryption functions available in MySQL (and so the plaintext input for the password has to e encrypted before it's compared to the database password). When retrieval is requested, an SQL select command must be executed to retrieve the entries for that requestor in the Incident table.AND HTML WRAPPER: Use PHP to wrap the results retrieved from the database in an HTML table which is returned to the browser as part of a retrieval response. Include a caption for the dynamically generated table which identifies the reporter name, and an initial row for the table that names the columns which include all the columns in the Incident table.

In phpmyadmin, i have three table

1) Authentication in which i have username, password, confirmpassword and email_address which authenticated the user so that the users submitted infor in entered in the database
2)Autorization is the next field. i have email_address, email_limit and email_number.
3) Logentry is the last table where i have 7 fields, the first one is just numbers, then name, email_address, desciption, category, priority and datetime. the main ones are the ones in the middle numbers, then name, email_address, desciption, category, priority.

If you want more info about this click on the link http://www.mediafire.com/download.php?cxx7kxc2s3bs9ev

Here's my HTML: http://www.mediafire.com/download.php?23v881y6ef2go00
Here's my PHP: http://www.mediafire.com/download.php?5ssgm8ggc18mfga

Again any help will be greatly appreciated so please comment and help a friend out :) Thanks.

Recommended Answers

All 6 Replies

Post the code here and ask specific questions.

Sorry, but I have enough of my own assignments to do....on the other hand...you could post parts of your code where you think you need help...then we could help without having to d/l, open and search through your code :-)

This is my php

<?php
include ("account.php");
include ("connect.php");


    $name =                 $_POST[ "Name" ];
    $password =             $_POST[ "Password" ];
    $confirmpassword =      $_POST[ "Cpassword" ];
    $emailaddress =         $_POST[ "Email" ];
    $description =          $_POST[ "Description" ];
    $category =             $_POST[ "Category"];
    $emailcopy =            $_POST[ "Emailcopy"];
    $priorityofrequest  =   $_POST[ "Priority" ];

    echo "Name='$name', Password='$password', CPassword='$confirmpassword', Email='$emailaddress', Description='$description', Category='$category', Emailcopy='$emailcopy', Priority='$priorityofrequest'";

    $q="SELECT name, password, confirmpassword, email_address FROM Authentication WHERE Name = '$name' AND Password = '$password' AND confirmpassword = '$confirmpassword' AND email_address = '$emailaddress' ";
    $login_check = mysql_query($q);
    echo"select is $q";


echo "<br><br>";
if( mysql_num_rows($login_check) > 0)
{
        $LOGinsert = "insert into Logentry values (NULL, '$name', '$emailaddress', '$description', '$category', '$priorityofrequest', Now())"; 
        echo "<br>$LOGinsert<br>";
        mysql_query($LOGinsert) or die ( mysql_error ()) ;

        echo " Hello, ".$name." <br>"
        ."Your entry is successfully updated. <br>";

    // "Your Incident of" .$category. "reported on" .Now()." is as follows: <br>"
    //  .$description.;

    //Email Request
    if($emailcopy == 'yes')
    {
        echo "Email Sent";
        } 
        else
        {
            $email_q="SELECT email_address, email_limit, email_number FROM Authorization WHERE `email_address` = '$emailaddress' LIMIT 1";
            $email_limit = mysql_query($email_q);
            $rows=mysql_fetch_array($email_limit);
            if($rows['email_number'] < $rows['email_limit'])
            {
                $to = $emailcopy;
                $from = 'ckp22@njit.edu';
                $header = "From: $from \r\n";
                $header .= "Content-type: text/html; charset=iso-8859-1" . "\r \n";
                $subject = "Incident Report Copy";
                $message = '<html>
                                            <b>Your requested E-mail copy...</b>
                                            <p></p>
                                            <h3>Hello, '.$name. '</h3>
                                            <font color="red">Your Log Message is : </font>'.$description.'<br><br><br>
                                            <p> Thank You </p>
                                            </body></html> ';

                    mail($to, $subject, $message, $header);
                    echo '<h3> your copy has been sent through email.<br></h3>';
                $update = $rows['email_number']+ '1';
                $email_update="UPDATE Authorization SET `email_number` = '$update' WHERE `emailaddress` = '$emailaddress' ";
                mysql_query($email_update);
            }else { echo 'Email copy limit is exceeded'; }
        }
    }
else
{

} 
?>

AND THIS IS MY HTML

<html>
<head>
<script>

function showinsert(){
    document.getElementById("insert").style.display = "block"
    document.getElementById("retrieve").style.display = "none"
}

function showretrieve(){
    document.getElementById("insert").style.display = "none"
    document.getElementById("retrieve").style.display = "block"
}

function compare ()
{
    var v1 = document.getElementById("p1").value
    var v2 = document.getElementById("p2").value
    if (v1 != v2){
        document.getElementById("s1").innerHTML = "Warning, Passwords don't match!"
        document.getElementById("s1").style.background = "red"
    }
    else{
        document.getElementById("s1").innerHTML = ""
    }
}

function compareretrieve()
{
    var v1 = document.getElementById("d1").value
    var v2 = document.getElementById("d2").value
    if (v1 != v2){
        document.getElementById("a1").innerHTML = "Warning, Passwords don't match!"
    document.getElementById("a1").style.background = "red"
    }
    else{
        document.getElementById("a1").innerHTML = ""
    }
}
</script>
</head>
<body>
<fieldset>
<label><b>Click the button for  the services you want!</b></label> <br>
<input type="button" value="Insert Incident" onclick="showinsert()" /></input>
<input type="button" value="Retrieve Incident" onclick="showretrieve()" /></input>
<link rel="stylesheet" href="as2style.css" type="text/css" media="screen">
</fieldset>

<form action ="incident.php" method="POST">

<div id="insert" style="display:none";>
<fieldset>
    <legend><b>INSERT</b></legend>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>Name</label>

    <input type="text" name="Name" placeholder= "Enter User Name" autofocus autocomplete="off" required="required"/>&nbsp;&nbsp;&nbsp;<br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>Password</label> 

    <input type="password" name="Password"id="p1" placeholder= "Enter Password" id="p1"/> <br>

<label>Confirm Password</label>

    <input type="password" name="Cpassword" id="p2" onblur = "compare()"  placeholder= "Enter Password" id="p2"/>  <br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>Email address</label>
<input name="Email" placeholder= "Enter your email address" required="required"/><br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="vertical-align: top;" >Description</label>

    <textarea name="Description" placeholder="Whats your incident?" rows = 2 cols = 17 required="required" ></textarea><br><br>

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>Category</label>

<select name="Category" >

    <option>Hardware</option>
    <option>Network</option>
    <option>System</option>

</select><br><br>


<label> Do you want a copy?</label>
<input type=radio name="Emailcopy" type="" value="yes">Yes    <input type=radio name="Emailcopy"value="no">No<br><br>

<label>Priority of request</label>

<label>1</label> <input name="Priority" type="range" min ="1" max ="5" value="1" step="1" /><label>5</label><br>


<span id = "s1" ></span><br>

<input type="submit" value="Submit" /> <br><br>
</fieldset>

</form>
</div>

<div id="retrieve" style="display:none;">
<form action ="incident.php" method="POST">

<fieldset>
    <legend><b>RETRIEVE</b></legend>    

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>User Name</label> 

    <input type="text" name="name" placeholder= "Enter User Name" /><br><br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>Password</label> 

    <input type="password" name="Password"id="d1" placeholder= "Enter Password" id="d1" /><br>

<label>Confirm Password</label> 

    <input type="password" name="CPassword"id="d2" onblur = "compareretrieve ()"  placeholder= "Enter Password" id="d2"/><br>
 <br>
 <label> Do you want a copy?</label>
<input type=radio name="Emailcopy"value="yes">Yes    <input type=radio name="emailcopy"value="no">No<br><br>

 <span id = "a1" ></span><br>

            <input type="submit" value="Submit" /> <br><br>
</fieldset>

</form>
</div>

</body>
</html>

Everythings working fine except the email sending....i dont know why it doesnt work?

if you are using likes of XAMPP on your local machine sendig emails will not work unless you have a mail server or setup a php mail server query

Try updating the if($rows['email_number'] < $rows['email_limit']){ section to this:

<?php
if($rows['email_number'] < $rows['email_limit']){
    $to = 'test@njit.edu';
    $from = 'ckp22@njit.edu';
    $header = "From: $from \r\n";
    $header .= "Content-type: text/html; charset=iso-8859-1" . "\r \n";
    $subject = "Incident Report Copy";
    $message = '<html>
        <body>
        <b>Your requested E-mail copy...</b>
        <p></p>
        <h3>Hello, '.$name. '</h3>
        <font color="red">Your Log Message is : </font>'.$description.'<br><br><br>
        <p> Thank You </p>
        </body>
        </html>';
    error_reporting(E_ALL);
    if(mail($to, $subject, $message, $header)){
        echo '<h3> your copy has been sent through email.<br></h3>';
        $update = $rows['email_number']+ '1';
        $email_update="UPDATE Authorization SET `email_number` = '$update' WHERE `emailaddress` = '$emailaddress' ";
        mysql_query($email_update);
    }else{
        echo 'mail error';
    }
}else{
    echo 'Email copy limit is exceeded';
}
?>

I'd imagine you wouldnt want users to pay for emails that fail to send!

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.