
rx3mer
Members-
Posts
46 -
Joined
-
Last visited
Everything posted by rx3mer
-
Hello! Pretty simple PHP form, I broke it..please assist! :)
rx3mer replied to teanza's topic in PHP Coding Help
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 = "[email protected]"; $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. -
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
-
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!
-
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?
-
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!
-
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?
-
Its all done. I passed the values on click with jquery.
-
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!
-
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?
-
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!
-
Can you not do something like: img, #sitemap ul li a, div.popular { display: inline-block; height: 100px; }
-
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
-
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>
-
Hi guys, I am trying to figure out how to pass PHP ID (page.php?id= 'id' ") with ajax request. Getting the ID and storing it into variable called "playlistsongid" <?php session_start(); if(!isset($_GET['id'])) die("No id set"); ?> <?php $playlistsongid = $_GET['id']; ?> function setupyoutubesongarray(firstload) { $.ajax({ 'url': 'post.php', 'async': false, success: function (response) { var posturl="post.php"; // needs to looks something like post.php?id= $.getJSON(posturl,function(data){ youtubesongs = []; $.each(data.members, function(i,song){ result = (song.SongUrl); youtubesongs.push(result); //ytplayer_playlist.push(result); }); loadnextbatchfromsongsarray(); if (firstload = 1) { ytplayer_render_player(); } }); } }); } Any help would be much apreceated!
-
I think the problem comes from the song not being loaded instantly on the page. If i do this "ytplayer_playlist.push('tGvHNNOLnCk');" it works, but when i add the veriable "ytplayer_playlist.push(result);" it doesen't work...
-
Hi guys, I am trying to build a simple web app that takes data from database, converts it into jason and inserts the data into a veriable that should act as a playlist. I want to make the veriable called "songs" to be equals the result and insert it into ytplayer_playlist. Any guides will be very helpfull! var songs; function addsongs(event) { $.ajax({ url: 'post.php', success: function (response) { var url="http://localhost/xampp/websites/youtubeAPI/post.php"; $.getJSON(url,function(data){ $.each(data.members, function(i,song){ result = (song.SongUrl); console.log(result); }); }); } }); } ytplayer_playlist.push('tGvHNNOLnCk');
-
Problem solved. Had to pass on the ID with GET and then I can store it in a session.
-
Replace this and let me know if it works. #nav { position:absolute; top: 110px; left: 175px; height: 2.3em; background-color:#666; right: 0; z-index: 2; }
-
Hi guys, I am trying to pass an ID with a session to another page. -------- ID: 10 - edit link -------- ID: 11 - edit link -------- ID: 12 - edit link -------- The problem that I am having is that the session stored is always the last ID, in this case 12. $info["HostID"]; comes from the DB. <?php $link = $info["HostID"]; echo '<td><a href="edit.php?id='.$link.'">Edit</a></td>'; ?> <?php if(isset($_GET['$link'])){$_SESSION['hostid'] = $_GET['$link'];} ?> Any suggestions?
-
Hey guys, I was just woundering what would be the best way of writing multiple popup functions? I can copy the code few times and change the ID but that doesen't sound efficeint. <script type="text/javascript"> var popUpActive = false; $(document).ready(function(){ //open popup $("#pop").click(function(){ if(popUpActive == false){ $("#flyout").fadeIn(150, function(){ popUpActive = true; }); } }); $(document).click(function(){ if(popUpActive == true) $("#flyout").fadeOut(150, function(){ popUpActive = false; }); }); }); </script>
-
Hey guys, I am looking for some web based ideas that I could develop for my last year of university. Any ideas? It could be web app or just a website, but it has to have some sort of database logic behind it.
-
problem solved. It was the CSS