Evening,
I'm creating a ticket system but running into an error at the moment. First I have to say that I'm quite new to mysqli and sorting it out by trying and googling ofcourse.
I have a table with 15 fields that needs to be filled (id is auto increment).
The first 5 fields have the correct input, but when I input the message, it's all messed up.
The message is HTML (using imap to connect to the mailserver and fetch the messages) but in some way it looks like the code is being split up. When I look at the table after the query, the biggest part of the HTML is being added in the field "message", but 2 parts are inserted in the wrong fields.
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.E-mailStijl17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:NL">Met vriendelijke groet/Kind regards,<br>
<br>
Cris Kolkman<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:NL"><a href="mailto:EMAIL">EMAIL</a><br>
<br>
<img border="0" width="125" height="39" id="Afbeelding_x0020_1" src="cid:image001.png@01D0C470.361FA850" alt="logo"><br>
COMPANY_NAME<br>
</span><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F4E79;mso-fareast-language:NL">ADDRESS<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F4E79;mso-fareast-language:NL">POSTAL_CODE</span><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:NL"><br>
Is going into the field message, so that is correct, but:
+31 (0)PHONE_NUMBER<br>
Is going into the field timestamp and:
+31 (0)PHONE_NUMBER</span><span style="mso-fareast-language:NL"><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:NL">E: <a href="mailto:EMAIL">EMAIL</a></span><span style="mso-fareast-language:NL"><o:p></o:p></span></p> <p class="MsoNormal"><o:p> </o:p></p> </div> </body> </html> <br><br>
In the field toName, while both inputs belong in message. Because of this happening all the other inputs after message go into the wrong field. Same behavior when I strip_tags() the message for plain text input into the message field.
Here is my query:
public function create_ticket($fromName,$fromEmail,$comp,$contact,$subject,$msg,$time,$toName,$toEmail,$ownerID,$ticketStatus,$ticketType,$timeSpend,$locked,$queue){
$query = "INSERT INTO tickets (senderName, senderEmail, companyID, userID, subject, message, timestamp, toName, toEmail, ownerID, ticketStatus, ticketType, timeSpend, locked, queue)
VALUES ('".$fromName."', '".$fromEmail."', '".$comp."', '".$contact."', '".$subject."', '".$msg."', '".$time."', '".$toName."', '".$toEmail."', '".$ownerID."', '".$ticketStatus."',
'".$ticketType."', '".$timeSpend."', '".$locked."', '".$queue."')";
if(!$GLOBALS['db_con']->query($query)){ echo 'Query wrong: ' . $GLOBALS['db_con']->error; }
$result = $GLOBALS['db_con']->insert_id;
$GLOBALS['db_con']->close();
return $result;
}
Also tried the mysqli real escape for $msg without success. Anyone has any clue what's going wrong?
Thanks in advance!!