Jump to content

rx3mer

Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Interests
    Web

rx3mer's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey, I haven't done the checks for each input but the script should work. PHP file <?php $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $selection = $_POST['selection']; $comment = $_POST['comment']; $to = "xxxx@email.com"; $subject="XXX Web Inquiry"; $message=""; $message.= "Hello,<br><br>\n"; $message.="<b>Name:</b> ".$name.".<br><br>\n"; $message.="<b>Email:</b> ".$email."<br><br>\n"; $message.="<b>Phone:</b> ".$phone."<br><br>\n"; $message.="<b>Selection:</b> ".$selection."<br><br>\n"; $message.="<b>Comment:</b> ".$comment."<br><br>\n"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From:".$name."<".$email.">\r\n"; $headers .= "Reply-To:".$name."<".$email.">\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; $headers .= "X-Priority: 1"; mail($to,$subject,$message,$headers); if (isset($HTTP_REFERER)) { echo "Your email has been send! | <a href='$HTTP_REFERER'>back</a>"; } else { echo " Your email has been send! | <a href='javascript:history.back()'>back</a>"; } ?> You don't need to change anything in the html file.
  2. I had to slightly modify the code to make it work without errors, but I am still having the same issue. INSERT INTO data (user_id, identifier_name, pos_x, pos_y, window_width, window_height, status) VALUES (1, '.testimonial', '1119', '316', '1663', '608', 'ok') INSERT INTO data (user_id, identifier_name, pos_x, pos_y, window_width, window_height, status) VALUES (1, '#header', '723', '66', '1663', '608', 'ok') New record created successfully Only the last INSERT has been done: Updated code: <?php $servername = "localhost"; $username = "root"; $password = "password"; $dbname = "clickmap"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $clicks = '.testimonial;1119;316;1663;608;#header;723;66;1663;608'; $keys = array('identifier_name', 'pos_x', 'pos_y','window_width','window_height'); $arr = explode(';', $clicks); $data = array_chunk($arr, 5); foreach ($data as $rec) { $sql = "INSERT INTO data (user_id, " . join(', ', $keys) . ", status) VALUES "; $sql .= "(1, '" . join("', '", $rec) . "', 'ok')";; echo $sql . '<br>'; } if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> Really strange
  3. I am using AJAX to send an array of values to a PHP page that will insert the data into MySQL database. For some reason only the last 5 values are inserted into the MySQL database and I am woundering how to fix that. I am using foreach loop. AJAX Request: Array: [".testimonial", 1119, 316, 1663, 608, "#header", 723, 66, 1663, 608] Posting the array: Sending Array Parameters using " ; " to split. clicks .testimonial;1119;316;1663;608;#header;723;66;1663;608 Source Sent: clicks=.testimonial%3B1119%3B316%3B1663%3B608%3B%23header%3B723%3B66%3B1663%3B608 PHP Page <?php $clicks = $_GET["clicks"]; $clickArray = explode(";",$clicks); $arrays = array_chunk($clickArray, 5); $servername = "localhost"; $username = "root"; $password = "password"; $dbname = "clickmap"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $keys = array('postIdentifier', 'postPos_x', 'postPos_y','postWindowWidth','postWindowHeight'); foreach ($arrays as $array_num => $array) { $values = array(); foreach ($array as $item_num => $item) { $values[] = $item; } $data = array_combine($keys, $values); extract($data); // now your variables are declared with the right values http://php.net/manual/en/function.extract.php $sql = "INSERT INTO data (user_id, identifier_name, pos_x, pos_y, window_width, window_height, status) VALUES ('1', '$postIdentifier', '$postPos_x', '$postPos_y','$postWindowWidth','$postWindowHeight', 'ok')"; } if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> Is this the correct way of coding it, and why does it post only the last 5 values? Any help would be much appreciated!
  4. Hi guys, I have a select option list with different values that come from MYSQL. 1,2,3,4,5,6 etc... Basically when I select one, and then change my mind and select another option from the list 2 of the values are stored and parsed to my ajax. I tried different methods such as empty(); inside the optionbox on click but nothing seems to reset it. $(".optionbox").click(function(){ var CASE_ID = $(this).attr('playlistID'); console.log(CASE_ID); $(".invite").click(function(){ $.ajax({ type:'POST', url:'processing/invite-user.php', data:'playlistID=' + CASE_ID, success:function(data) { if(data) { // DO SOMETHING } else { // DO SOMETHING } } }); }); }); Basically all i want is the last selected value to be passed to the invite on click. Any suggestions?
  5. I just found that MySQL can convert Queries to PHP. I know its probably not the best way to go, but I don't have much time at the moment. SELECT *\n". "FROM playlists\n". "WHERE HostID IN (\n". "SELECT HostID\n". "FROM HOSTS\n". "WHERE UserID = 33)" Thank you for your response!
  6. Hi guys, First of all I am new to this. I managed to create simple inner join request that displays some results. The problem I am having is that the results come up in the HeidiSQL software but they won't come on the page once coded. include("../includes/config.php"); mysql_connect("$host", "$username", "$password")or die("cannot connect"); $link = mysql_select_db("$db_name")or die("cannot select DB"); $data = mysql_query("SELECT * FROM playlists WHERE HostID IN (SELECT HostID FROM hosts WHERE UserID = 33 ") or die(mysql_error()); while($info = mysql_fetch_assoc( $data )) { ?> <?php ?> <ul> <li> <div> <span>Name: <?php echo $info['PlaylistName']; ?></span> </div> </li> </ul> <?php } ?> I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 I am using MySQL and PHP Any ideas?
  7. Its all done. I passed the values on click with jquery.
  8. gristoi it worked after some testing. Basically what I was getting wrong was the id name on my div element. <div class="delete_class delete" ID="<?php echo $info['PlaylistSongID']; ?>">Delete</div> Thank you very much!
  9. Yeah that it. I will think about it, give it a try and I'll come back with an update. Thanks for your time!
  10. I don't think that you understand my question, or I just don't understand your answer. I know how to make the function run on click. The problem I am having is that I don't know how to pass the values to the ajax as data. Any ideas?
  11. rx3mer

    Image Viewer

    background-size: 100% 100%; Or http://css-tricks.com/how-to-resizeable-background-image/
  12. Hi guys, I am trying to delete DB row without page refresh. I am aware of how to delete by passing URL values and I am trying to do the same thing, but with AJAX. $data = mysql_query("SELECT * FROM playlistsongs WHERE PlayList = '$playlistsongid'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { ?> <?php <table border="1px"> <tr> <td style="width: 100px;"><?php echo "<b>PlaylistSongID:</b> ".$info['PlaylistSongID'];?></td> <td style="width: 100px;"><?php echo "<b>PlayList:</b> ".$info['PlayList'];?></td> <td style="width: 100px;"><?php echo "<b>UserID:</b> ".$info['UserID'];?></td> <td style="width: 100px;"><?php echo "<b>SongUrl:</b> ".$info['SongUrl'];?></td> <td style="width: 100px;"><?php echo "<b>Status:</b> ".$info['Status'];?></td> <td style="width: 100px;"><?php echo "<b>DateCreated:</b> ".$info['DateCreated'];?></td> <td style="width: 100px;"><?php echo "<b>DateModified:</b> ".$info['DateModified'];?></td> <td style="width: 100px;"><?php echo "<b>Artist:</b> ".$info['Artist'];?></td> <td style="width: 100px;"><?php echo "<b>Title:</b> ".$info['Title'];?></td> <td style="width: 100px;"><a data-customer-id="345" class="button remove">Remove</a></td> </td> </tr> </table> And this is my AJAX request: function DeletePlayListItem(){ $.ajax({ 'url': 'processing/delete-playlist-items.php', 'async': false, data: "PlaylistSongID=" + PlaylistSongVarID + "&UserID=" + UserVarID + "&Status=", success: function (response) { var posturl='http://localhost/xampp/websites/Djapp/processing/delete-playlist-items.php' $.getJSON(posturl,function(data){ $.each(data.members, function(i,userdetails){ takeuserid = (userdetails.UserID); title = (userdetails.Title); vote1 = (userdetails.Vote1); }); }); } }); } So my question is, how do I pass the values to the AJAX on click/select? Thank you for your time!
  13. Can you not do something like: img, #sitemap ul li a, div.popular { display: inline-block; height: 100px; }
  14. Hi guys, This could be very simple but I am not sure what to search for and how it works. I have a Youtube Search function that brings a lot of videos with different values. For example [videoid] could be equal = CGyAaR2aWcA. [videoname] could be equal "the walking dead" and so on... Example html result: <li> 2 States - Official Trailer - Arjun Kapoor, Alia Bhatt (CGyAaR2aWcA<a href=http://www.youtube.com/watch?v=CGyAaR2aWcA?version=3&enablejsapi=1 target=_blank> Watch This Video</a> <img src=http://img.youtube.com/vi/CGyAaR2aWcA/0.jpg />) </li> <li> WHAT IS WRONG WITH YOU?! - The Walking Dead - Season 2 - Episode 2 - Part 2 (dsXhuOwPTTc<a href=http://www.youtube.com/watch?v=dsXhuOwPTTc?version=3&enablejsapi=1 target=_blank> Watch This Video</a> <img src=http://img.youtube.com/vi/dsXhuOwPTTc/0.jpg /><input type='submit' value='Add Song' name='create' />) </li> I want to be able to select one of the lists and insert the data into MYSQL DB. I already have a form with inputs that I have tested and works. What is the method of doing that kind of selections? Rad
  15. Thank you! Just had to convert the php to js veriable and the job was done. <?php $var = "a value"; ?> <script> jsvar = '<?php echo $var ;?>'; alert(jsvar); </script>
×
×
  • 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.