Jump to content

JonnyDriller

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by JonnyDriller

  1. No way... facepalm... ahh well I think I learned a good bit. Legend @ginerjm thx m8
  2. I have a situation were I need to just get a simple location. I don't want any while loops or any of that jazz. I just want 1 string location every time. <?php $ider = $_GET['id']; $conn = mysqli_connect("localhost", "Me", "pass", "MyDB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT Location FROM LifeSaver1 WHERE id =$ider"; $result = $conn->query($sql); $obj = mysqli_fetch_object($result); $obj2 = $obj->Location; var_dump($obj); ?> This is what it outputs I just need Boston. Can anyone give me a hint?
  3. I also think this stupid code has fried my database - with the following error... The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here...sigh....so tired
  4. I just combined them as you see it @Kicken. Only all one script, saved as a PHP file. I've gotten a bit further with the troubleshooting. I've taken just code one and put it on it's own page. Something weird happens If I have blank <?php?> tags the page displays as a blank white page. So I put in the script - shown in Code 1. Now If I use the echo statements - if I echo $thisloc it displays the page with the echo eg. New york if I echo the $JSONloc it prints again only like this - "New York" However if I switch off all the echo statements - it says the page cannot be displayed. All I need is one value matched to the id. This is probably a bad way to do the PHP script. But after a few hours struggling I found this which prints out an array. then I just trimmed it down till I found the variable that I needed.
  5. I've tried another test where I remove my PHP code. Gave it php tags told it to echo "test"; and it loads it and the google map file fine. I might see if I can call this Json var from another file
  6. I've created both the scripts below. Which seem to work well on their own. The scripts are not interacting at the moment, however I do intend to use this lil $JSONloc (json encoded variable) from code 1, in Code 2. But they are not interacting atm. The Json variable is just a return from a database eg. "New York." and it returns whatever id I give it working fine. This map script = code 2: Will eventually plot a number of locations. Only 1 is set atm, but I've tested it with more, and it runs fine again on its own. The problem is when I run both scripts together I get problems. In this case it echos the location fine but it doesn't load the map. Ok so remove the echo statement... and then it says Page cannot be displayed Ok so remove the PHP and the map works fine. Like WTH? Do these things even work together? I'm at this 1 day and a half. Please help I've changed the personal details for security. Code 1 <?php $ider = $_GET['id']; $host = "localhost"; $user = "user"; $password ="pass"; $database = "DB1"; mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // connect to mysql database try{ $connect = mysqli_connect($host, $user, $password, $database); } catch (mysqli_sql_exception $ex) { echo 'Error'; } $sql = "SELECT id, Location FROM Db1 WHERE id =$ider"; $result = $connect->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $thisloc = $row["Location"]; //get array data $JSONloc = json_encode($thisloc); //change to JSON echo $JSONloc; //test } } else { echo "0 results"; } $conn->close(); ?> Code 2 <!DOCTYPE html> <html> <head> <title>Custom Markers</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 90%; width: 70% margin: 0; padding: 0; } </style> </head> <body> <div id="map"></div> <script> var map; function initMap() { map = new google.maps.Map( document.getElementById('map'), {center: new google.maps.LatLng(64.009094, -7.316163), zoom: 13}); var iconBase = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/'; var iconBase2 = 'http://icons.iconarchive.com/icons/paomedia/small-n-flat/32/'; var icons = { // different icons for the map equipment: { icon: 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/32/Map-Marker-Marker-Outside-Azure-icon.png' }, library: { icon: iconBase2 + 'map-marker-icon.png' }, info: { icon: iconBase + 'info-i_maps.png' } }; var dormant = 'equipment'; var active = 'library'; var later = 64.013376; var longer = -7.307036; // static variables for testing var features = [ { position: new google.maps.LatLng(later, longer), type: active } ]; // Create markers. for (var i = 0; i < features.length; i++) { var marker = new google.maps.Marker({ position: features.position, icon: icons[features.type].icon, map: map }); }; } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=bla&callback=initMap"> </script> </body> </html>
  7. Soz guys I wrapped it in a Div and stuck it at the bottom of my code. Seems to have worked out <?php $uri = $_SERVER['REQUEST_URI']; $uri_dir = getcwd(); ?> <!DOCTYPE html> <html> <head> <link href="/LifeSaverHTML/Details/Database/stylevid2.css" rel="stylesheet" type="text/css"> <h1 class = "titler"> LifeTube </h1> <p></p> <nav> <ul> <li> <a href="/home.php">Home</a> </li> <li> <a href="/LifeSaverHTML/Database.php">Database</a> </li> <li> <a href="/LifeSaverHTML/mapper.php">GPS Map</a> </li> <li> <a href="/LifeSaverHTML/UpdateSearch.php">Update and Search</a> </li> <li> <a href="/LifeSaverHTML/Details/Database/index.php">Video</a> </li> </ul> </nav> <p></p> </head> <body> <video class = "tube" controls src="examplevid.mp4"> Your browser does not support the video tag. </video> <p></p> <div style="margin: 0 auto; text-align: center"> <a href='/PHPMailer/index.php?id=<?=$uri?>&dire=<?=$uri_dir?>' class="linker">Email Security</a> </div> </body> </html> ?php if(isset($_GET['Message'])){ echo "<div id='emailmess'>"; echo $_GET['Message']; echo "</div>"; } ?>
  8. I've been working on my email screen, adding a video to it, and some Css. Which seems to work quite fine. However when the page returns to the original screen (represented by the code 1.) It collapses the video image. Makes it really long horizontally and thin vertically. If I remove this first piece, showing that the email was sent successfully. if(isset($_GET['Message'])){ echo $_GET['Message']; } It returns to the screen fine and the video looks as it should. Code1:- <?php if(isset($_GET['Message'])){ echo $_GET['Message']; } $uri = $_SERVER['REQUEST_URI']; $uri_dir = getcwd(); ?> <!DOCTYPE html> <html> <head> <link href="/LifeSaverHTML/Details/Database/stylevid2.css" rel="stylesheet" type="text/css"> <h1 class = "titler"> LifeTube </h1> <p></p> </head> <body> <video class = "tube" controls src="examplevid.mp4"> Your browser does not support the video tag. </video> <p></p> <div style="margin: 0 auto; text-align: center"> <a href='/PHPMailer/index.php?id=<?=$uri?>&dire=<?=$uri_dir?>' class="linker">Email Security</a> </div> </body> </html> I'm using this piece of CSS = Code2. I've set all the defaults padding etc to default for testing. * { margin: 0; padding: 0; } As I say it looks great. Apart from when it returns with the email successful message. The whole thing just deflates. Code2:- * { margin: 0; padding: 0; } body { background: url('/LifeSaverHTML/Details/Database/backround.jpg') no-repeat center center fixed; height: 100%; background-position: center; background-repeat: no-repeat; background-size: cover; } .tube { display: block; margin: auto; width: 50%; height: 20%; border: 10px solid green; } .button { margin: 0 auto; display:block; text-align: center; } .linker { background-color: #23b83c; border: 2px solid #020353; color: whitesmoke; padding: 1em 1.5em; text-align: center; text-decoration: none; font-size: 1em; display: inline-block; width: 12%; border-radius: 5px; box-shadow: 3px 3px 8px 0 #000; /* h-offset v-offset blur spread color */ } .linker:hover { color: red; } .titler { width: 20%; text-align: center; margin: 0 auto; color: #FFFFFF; border: 5px ridge rgba(124,252,0); border-radius: 36px; background: #232323; text-shadow: 0 0 5px #FFF, 0 0 10px #FFF, 0 0 15px #FFF, 0 0 20px #49ff18, 0 0 30px #49FF18, 0 0 40px #49FF18, 0 0 55px #49FF18, 0 0 75px #49ff18; } nav { width: 80%; margin: 0 auto; } nav ul { list-style: none; overflow: hidden; } nav ul li { float: left; width: 20%; } nav ul li a { text-align: center; padding: 8px 0; display: block; width: 100%; background: #cdeb8e; /* Old browsers */ background: -moz-linear-gradient(top, #cdeb8e 0%, #b0ca34 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#b0ca34)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #cdeb8e 0%,#b0ca34 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #cdeb8e 0%,#b0ca34 100%); /* Opera 11.10+ */ background: linear-gradient(to bottom, #cdeb8e 0%,#b0ca34 100%); /* W3C, IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#cdeb8e’, endColorstr=’#b0ca34′,GradientType=0 ); /* IE6-9 */ } nav ul li a, nav ul li a:focus, nav ul li a:visited, nav ul li a:hover, nav ul li a:active { color: #000; text-decoration: none; } nav ul li a:hover, nav ul li a:active { background: #b0ca34; /* Old browsers */ background: -moz-linear-gradient(top, #b0ca34 0%, #96c40d 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b0ca34), color-stop(100%,#96c40d)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #b0ca34 0%,#96c40d 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #b0ca34 0%,#96c40d 100%); /* Opera 11.10+ */ background: linear-gradient(to bottom, #b0ca34 0%,#96c40d 100%); /* W3C, IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#b0ca34′, endColorstr=’#96c40d’,GradientType=0 ); /* IE6-9 */ } nav ul li:first-child a { border-top-left-radius: 8px; border-bottom-left-radius: 8px; } nav ul li:last-child a { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
  9. Thanks guys for the great advise. When all this is over and done, I'm gonna revisit web development on a nice platform, with a proper text editor... i.e not a Raspberry pi that existed 2 decades ago This IOT project is gonna sit on a localhost...yeh I know... So it doesn't have to be super secure. I'm gonna do a screen recording of it and then I'm going to trim it down to make it have a much functionality as possible for a demo on the university Lan. The thing doesn't have wifi and things are not allowed on the Uni network...😂 the joys...
  10. Interestingly I actually needed the whole path for that one. It wanted the complete path to send an attachment in PHPMailer. It wouldn't take the /LifeSaverHTML/Details/20 It wanted the whole /var/www/html/LifeSaverHTML/Details/20 This code does it though there's probably one of those server commands would work too. $uri_dir = getcwd();
  11. Sorry guys I got it: - $uri_dir = dirname($_SERVER['REQUEST_URI']); echo $uri_dir; Might come in handy for someone in future
  12. I need to assign my current folder path to a variable. I keep getting this:- What I want is this:- That full path does weird stuff. Sometimes when I'm editing files, it's like I'm editing a ghost copy but not the actual file... Weird anyways. Below is some of the attempts I've tried... If I use this command:- //$uri = $_SERVER['REQUEST_URI']; It will give me what I need but with index.php tacked onto the end:- <?php //$pa = $_SERVER['PATH_TRANSLATED']; //echo $pa; //$uri = string dirname ( $path ); //echo $uri; //$ echo $PWD // current directory // current directory //echo getcwd() . "\n"; //chdir('cvs'); // current directory //echo getcwd() . "\n"; //$pa = basename(__DIR__); //echo $pa; //$pa = dirname(__FILE__); //echo $pa; $cur_dir = explode('\\', getcwd()); echo $cur_dir[count($cur_dir)-1]; ?> This first one returns a blank page without error, there's one that will return just the directory most are the www stuff. I suppose I could edit the string but surely there must be a function?
  13. Maxxd thx for the extra info. Sorry I've had this link open all this time, buried deep in my multiple research windows. I'm stuck at a part of this that I thought would be as easy as pie. Seeming not... sigh... gonna open another thread for it though as it's kind of unrelated.
  14. That's worked out nicely to send that variable. I'm not sure if Href will tell the phpmailer page to send the email though. I seem to remember it needed the form post method... but I could be wrong. I've some test to set up here and see if it works. . Thanks once again, I definitely wouldn't be sitting at this point without your help. 3 months to go and am freeeeee from uni...soon this project will be done. Enjoyable but can't wait to get finished... I'll let you know if it works.
  15. Nice, so the <??> is telling it to use the php variable... kk I'll give it a whirl.
  16. Yeh sorry Barand - I just literally noticed the post and ran into the problem simultaneously. I'm thinking about removing this button and using the Href instead. I'm sure I can change the href with css if I need to. This is the code. It will go to a page that sends an email - I want a variable for the attachment location. It then comes back to this page with a header function returning "email sent" The href doesn't seem to recognise the $uri. My first thought is the HTML has a different scope than the php. But that doesn't seem to have been my experience so far with php and html... <?php if(isset($_GET['Message'])){ echo $_GET['Message']; } $uri = $_SERVER['REQUEST_URI']; ?> <html> <body> <a href='test.php?id=$uri'>link to page2</a> <!-- <form action="index.php" method="POST"> <button type="submit">Send</button> </form> --> </body> </html>
  17. Not always it would seem... funny I was just trying to resolve this, when I spotted the message about your post @gw1500se <a href='test.php?id=$uri&user=John'>Dispatch</a> Seems to recognise the $uri as a string. Actually now I look at it this is pretty much the same issue...
  18. 😂 Two hours later and it was the most simplest change to your code that got me the variable as well Barand..! <td> <a href='Details/$id/index.php?id=$id'>$id</a> </td> I was adding in {{}} and .$id. and all sorts to try and get it working. Lol I suppose the $ is telling it the next part of the string is the variable. Silly me... You're a legend sir! I've got to do another one lil complicated bit, now. Well complicated for me... and I think I've at least got the basic functionality of this project working.
  19. Hi guys; I've managed to find my way into something of a maze. <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> I'm looking at this line in the code. I realise it's currently in the wrong syntax but I'm just trying multiple different variations. At the moment I'm actually just trying to make it go to a static link but my real goal is to - get it to pick up the id number, of the id row I click, and concatenate that with the rest of my address string. Then use that as the href. Something like this: - "'Details/' + $id + '/index.php'" It's really confusing me though inside this loop and for some reason the id number is being picked up as an int, by the looks of things. It's getting above my level of understanding. Any chance one of you masters would through a n00b a lifeline? This is my code below <!DOCTYPE html> <html> <head> <title>LifeSaver DB</title> <h1> LifeSaver Database </h1> </head> <body> <table> <tr> <th>Id</th> <th>Location</th> <th>Initials</th> <th>TimeStamp</th> <th>Notes</th> </tr> <?php $conn = mysqli_connect("localhost", "meh", "pas", "DB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM LifeSaver1 ORDER BY id DESC"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { //for href row $id = $row['id']; $Footage = ['Footage']; echo "<tr> <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> <td>" . $row["Location"] . "</td> <td>" . $row["Initials"]. "</td> <td>" . $row["TimeStamp"]. "</td> <td>" . $row["Notes"] . "</td> </tr>";} //show table echo "</table>"; } else { echo "0 results"; } $conn->close(); ?> </table> </body> <style> table, td, th { border: 1px solid black; margin: auto; } table { border-collapse: collapse; color: #000; <!--font colour --> font-family: monospace; font-size: 18px; text-align: center;} th { background-color: #337AFF; color: white; font-weight: bold; } tr:nth-child(odd) {background-color: #add8e6} </style> </html>
  20. @Barand You're a legend ! Thx so much, most of the day I'm trying to do that... Finally I can sleep...
  21. I have this working script below. I never managed to turn it into a function... I think it's because there's classes in it. I stopped that investigation and instead I choose to:- keep it on another page, trigger it with the a <form> button, then return to the form page using header location. This is probably much more elaborate than it needs to be... but it seems to be working fine. I'd like to print out "email sent" if successful. The collection of confusion at the end of this script, is me trying to get it to return the - "email sent" message <index.php> <?php require 'includes/PHPMailer.php'; require 'includes/SMTP.php'; require 'includes/Exception.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = "true"; $mail->SMTPSecure = "tls"; $mail->Port = "587"; $mail->Username = "email@gmail.com"; $mail->Password = "pass"; $mail->Subject = "Test email using PhPmailer"; $mail->setFrom("email@gmail.com"); $mail->isHTML(true); //$mail->addAttachment('img/movie.mp4'); $mail->Body = "<h1>This is a HTML heading</h1></br><p>This is a html title</p>"; $mail->addAddress("email@gmail.com"); if ($mail->Send() ) { echo "Email sent..!"; } else{ echo "Error..!"; } $mail->smtpClose(); ob_start(); $Message = urlencode("Email Sent"); header("Location:EmailBut.html?Message=".$Message); die; ob_flush(); ?> The stuff at the beginning of this next script is me trying to get it to print out email sent. I can get it to return the message in the URL but it won't print out. <EmailBut.html> <?php ob_start(); if(isset($_GET['Message'])){ echo $_GET['Message']; } echo $_GET['Message']; ob_flush(); ?> <html> <body> <form action="index.php" method="POST"> <button type="submit">Send</button> </form> </body> </html> Can you please give me a push in the right direct here?
  22. Yeh I know... I changed it it's ok.. n00b move lol 🤔
  23. @requinix- Hi Requinix thx for the reply. I was beginning to think I had a internet smell. To my great relief during the course of the troubleshooting I was doing for you, I managed to get it working! I've used a simple script, which I posted at the bottom for anyone in future, who might view the thread. As a side note one of the troubleshooting steps I was trying yesterday was - to define the script as a function. Why doesn't this load? It just gives me error 500. As far as I can tell it's the right syntax. I know the script inside the function works and I know this syntax works? What am I missing? <?php function EmailScript() { require 'includes/PHPMailer.php'; require 'includes/SMTP.php'; require 'includes/Exception.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = "true"; $mail->SMTPSecure = "tls"; $mail->Port = "587"; $mail->Username = "***********@gmail.com"; $mail->Password = "***********"; $mail->Subject = "Test email using PhPmailer"; $mail->setFrom("*********@gmail.com"); $mail->isHTML(true); //$mail->addAttachment('img/LifesaverFootage.mp4'); $mail->Body = "<h1>This is a HTML heading</h1></br><p>This is a html title</p>"; $mail->addAddress("lifesaversecur@gmail.com"); if ($mail->Send() ) { echo "Email sent..!"; } else{ echo "Error..!"; } $mail->smtpClose(); } EmailScript(); ?> Here's the working script for anyone in future: - just put the EmailButton.html in the same directory as the php loading from index.php or make them on the same page and adjust the code. <html> <body> <form action="index.php" method="POST"> <button type="submit">Send</button> </form> </body> </html>
  24. I've tried a few variations with post as well as get too.
  25. I'm having problems creating a working submit button for a php script. The script is sitting on index.php and if I browse to that page it will send the email as required... great. So I though happy days I'll make a simple button for it... 6 hours later no joking. Firstly this is working php <?php require 'includes/PHPMailer.php'; require 'includes/SMTP.php'; require 'includes/Exception.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = "true"; $mail->SMTPSecure = "tls"; $mail->Port = "587"; $mail->Username = "Myemail@gmail.com"; $mail->Password = "Pass"; $mail->Subject = "Test email using PhPmailer"; $mail->setFrom("Myemail@gmail.com"); $mail->isHTML(true); $mail->addAttachment('img/LifesaverFootage.mp4'); $mail->Body = "<h1>This is a HTML heading</h1></br><p>Title</p>"; $mail->addAddress("myemail@gmail.com"); if ($mail->Send() ) { echo "Email sent..!"; } else{ echo "Error..!"; } $mail->smtpClose(); ?> Now I've been at this with everything but a blow torch these are some attempts below. I've also tried to just href to the page. All that happens is it creates another copy of the index.php file as if it were a download. The last thing I wanted to do was wrap this up as a function and I wanted to try something to do with Isset. But it won't even load the page if I define it as a function and then call it. I know I'm defining and calling the function correctly as I can do an echo function. Surely it couldn't be this hard. I mean all the thing has to do is dang trigger the page for goodness sake. Lol sighhhhhhh...Please help <!-- <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Email Button</title> </head> <body> <form action="index.php" method="get"> <input type="hidden" name="act" value="run"> <input type="submit" value="Run me now!"> </form> </body> </html>
×
×
  • 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.