Jump to content

Recommended Posts

To start off with I am really sorry if the title doesn't necessarily describe what I am trying to accomplish here and really didn't know how to title it.

 

What I have is a form that user inputs information and then when they hit submit it takes them to the page with the code to insert the information into the sql server database. This page also, will send an email out with the some of the information based on one of the fields the user input information into. When the information is inserted into the database, I have a column named RefNumber, that the column settings for it are as follows:

 

[RefNumber] [int] IDENTITY(1,1) NOT NULL

 

I want to have this RefNumber displayed out to the user as well as have it in the emails that are sent out as a confirmation for that the email is associated with. Here is my code that I currently and if any let me know if I need to explain anything more clearly:

 

<?php
session_start();
if (!(isset($_SESSION['forteid']) && $_SESSION['forteid'] != '')) {
header ("Location: login.php");
exit();
}
?>
<?php
error_reporting(E_ALL ^ E_NOTICE);
include 'includes/db_connect.php';
$CallDispo = $_POST['disposition'];
$NewNotes = str_replace("'", "", "$_POST[notes]");


if (trim($CallDispo) == "Revision" or trim($CallDispo) == "Revision/Save" or trim($CallDispo) == "Revision/Collection" or trim($CallDispo) == "Reinstatement") {
$to = "dawn.okeefe@srb1.com";
$subject = "Revision - $_POST[appnumber]";
$message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'>
 <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Finance Number:</td><td>$_POST[Finance_Num]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr>
 <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Discount Amount:</td><td>$_POST[Disc_Amount]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>New Total Cost:</td><td>$_POST[Total_Cost]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Total Monthly Payments:</td><td>$_POST[Total_MP]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>New MP Amount:</td><td>$_POST[New_MP_Amt]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>New DP Amount:</td><td>$_POST[New_DP_Amt]</td></tr>
 <TR style='border:0 solid black; text-align: Left;'><td></td><td></td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>";
}
elseif (trim($CallDispo) == "Escalation"){
$to = "jeremy.nemens@srb1.com";
$subject = "Escalation - $_POST[appnumber]";
$message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'>
 <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Finance Number:</td><td>$_POST[Finance_Num]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr>
 <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>";
}
elseif (trim($CallDispo) == "Email Contract"){
$to = "jeff.starke@srb1.com";
$subject = "Email Contract - $_POST[appnumber]";
$message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'>
 <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr>
 <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>";
}
elseif (trim($CallDispo) == "Send Contract/Invoice"){
$to = "nicole.lehew@srb1.com";
$subject = "Send Contract/Invoice - $_POST[appnumber]";
$message = "<Table border='1px' cellpadding='5' style='border:1px solid black; text-align: Left;'>
 <TR style='border:1px solid black; text-align: Left;'><td>ForteID:</td><td>$_POST[ForteID]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>AppNumber:</td><td>$_POST[appnumber]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Date:</td><td>$_POST[date]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Contract Number:</td><td>$_POST[Con_Number]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Finance Number:</td><td>$_POST[Finance_Num]</td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Phone Number:</td><td>$_POST[Phone_Num]</td></tr>
 <TR style='border:0px solid black; text-align: Left;'><td></td><td></td></tr>
 <TR style='border:1px solid black; text-align: Left;'><td>Notes:</td><td>$NewNotes</td></tr>";
}
$headers = 'From: nick.curran@srb1.com' . "\r\n" .
'Reply-To: nick.curran@srb1.com' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();


//Insert to form data into database
$tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num, num_payments, ach_cc, date, notes, Phone_Num, Cancel_Disposition, Con_Number, Post_Date, Total_Cost, Total_MP, New_MP_Amt, New_DP_Amt, Disc_Amount, Callback) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$parameters = array( $_POST[ForteID], $_POST[disposition], $_POST[appnumber], $_POST[Finance_Num], $_POST[num_payments], $_POST[ach_cc], $_POST[date], $NewNotes, $_POST[Phone_Num], $_POST[Cancel_Disposition], $_POST[Con_Number], $_POST[Post_Date], $_POST[Total_Cost], $_POST[Total_MP], $_POST[New_MP_Amt], $_POST[New_DP_Amt], $_POST[Disc_Amount], $_POST[Callback]);
$stmt = sqlsrv_query($connection, $tsql, $parameters);


// Send Email
if(mail($to, $subject, $message, $headers))
echo "Email sent!<br>";
else
echo "No email to be sent!<br>";


/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $connection);
header( "refresh:2;url=index.php" );
echo 'Your entry has been saved!';
exit();
?>


 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/273559-display-index-column-after-insert/
Share on other sites

Thanks for posting it here so the next person who has this problem can use your solution!

 

I'll go ahead and mark this solved for you.

 

 

(If I understand the question, the answer is mysql_last_insert_id())

Edited by Jessica
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.