Jump to content

Hughesy1986

Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by Hughesy1986

  1. http://uk2.php.net/eregi
  2. Well if you want to use javascript with your php, its best to use Ajax. So you could show a prompt saying account created and then they click ok to continue, then in your javascript you can check if the value is true. If it is redirect them to your chosen page.
  3. Ok I fixed it now, if you view the page in my first post, you will see its working now. The problem was I needed to addslashes($_POST['field']) because the <?php etc was makign the script crash. ive got it all too work now. Glen
  4. Hi, I am coding a new portfolio for myself at the moment, I have pretty much done everything now, you can see here. http://www.hughesy1986.com I am coding the tutorial part, now what I am doing is in the ACP i can code the whole script in there, in a textfield, then click add tut and it stores it in a blob format in my mysql database. The problem I am having is showing the php code, im using highlight_string to show the php syntax, but when I try and insert the new tutorial with <?php ?> in the fields, it is crashing. Now im adding stripslashes to try and stop it from dieing. Does anyone know a better way to do this? Page in question http://www.hughesy1986.com/new/index.php?page=tutorials Many Thanks Glen
  5. Not sure what you mean but there is the: $_FILES['filename']['tmp_name']; That shows the path where the file is waiting. Glen
  6. You could just count how many there are and then echo that one, if thats what you mean. Like: <?php $query = "SELECT * FROM users"; $result = mysql_query($query) or die (mysql_error()); $total = @mysql_num_rows($result); // error check if ($total == 0) { echo "None to show <br />"; }else{ // get the last one $id = $total; $query = "SELECT * FROM users WHERE id = '$id'"; $result = mysql_query($query) or die (mysql_error()); $row = @mysql_fetch_array($result); // error check if (!$row) { echo "None to show"; }else{ // set your values here echo $total; } } ?>
  7. Hi I would do it like this i havent tested it but it should work <?php session_start(); $username = addslashes($_POST['username']); $password = addslashes($_POST['password']); include('config.php'); $sql = "SELECT * FROM regcustomer WHERE username='$username' AND password = '$password'"; $query = mysql_query($sql) or die (mysql_error()); $row = @mysql_fetch_array($query); if ($row) { echo "It worked <br />"; $_SESSION['username'] = $row['username']; $user = $_SESSION['username']; echo "Logged in as $user <br />"; }else{ echo "Wrong username or password"; } ?>
  8. Wow you guys are harsh, lol if you wana flame people for wanting to learn just like you did why are you in the php help forums? Glen
  9. When people use yourpage?value=this&id=1 This is when you are sending information to your php script, using the $_GET[''] then to retrive that information you would use something like $name = $_GET['name']; Glen
  10. Are you sending the username value with the posted data? If you are not that is why they query is not working, use a hidden field like <input type="hidden" value="<?php echo $username; ?>" name="username" id="username">
  11. Hi, You need to use == instead of = <td> <?php if($_POST['a_button']){ if($_POST['a_name'] == ""){ echo "<b>You did not specify a name for the album"; }else{ mysql_query("INSERT INTO `p_albums` ( `userID` ,`name`, `cover`) VALUES ('$_SESSION[id]', '{$_POST['a_name']}', 'http://s191754240.onlinehome.us/files/nopic.JPG');") or die("There was an error creating your album"); } } ?> </td> </tr> <tr> <td><b>Create Album:</b></td><td><input type="text" name="a_name" maxlength="25" value="Album Name" /></td><td><input type="submit" name="a_button" value="-Create-" /></td> </tr>
  12. Hi, I am making a news system with just using file functions. Now what i want to do is get the files contents and show them in a text area but not as code as how it looks on the page. Is this possible? Thanks Glen
  13. Hi, Yeah thats what i was thinking, is there any php functions which can see if a url is clicked? Glen
  14. Hi guys! I am currently making a cms for my portfolio and in the script section I need to record the amount of times that a download has been clicked, how do i go about this? anyone know any good tuts? i dont want someone to do it for me just need pointing in the right direction, also i just want to write it to a txt file. Many Thanks Glen
  15. Worked perfect thanks alot, I had suspected that was the problem but couldnt figure out how to fix it, great mate thanks alot again! Glen
  16. Are you assining any values to $suppid or $compid? I just ran that code and it does not like the endif btw Glen
  17. Hi, I have tried to add that in but it wont let me edit my post sorry. The error is that, when i load the news say ?id=3 and change the entrys, what is happening is that it is updating it as news id=0 and not updating the correct one. Glen
  18. Hi guys! I have been making a news script in php and mysql its my first project ive done in mysql and im a bit stuck and really need some help. This script im making im gona release for free for everyone once its done. Ok the problem is im trying to make a update page and delete bit, whats happening is the id number isnt choosing the correct news when i update the table. Heres my whole code for the edit_news.php [code]<? require("connect.php"); $query = " SELECT * FROM news WHERE id='$id'"; $result = mysql_query($query); $num = mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id = mysql_result($result, $i, "id"); $news = mysql_result($result, $i, "news"); $title = mysql_result($result, $i, "title"); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <p>   <input type="hidden" name="ud_id" value="<? echo $id; ?>">   News ID: <input name="ud_id" type="text" value="<? echo $id; ?>" size="3" maxlength="3"> </p> <p>News Title:   <input name="ud_title" type="text" id="ud_title" value="<? echo $title; ?>"> </p> <p>News:<br>   <br>   <textarea name="ud_news" cols="75%" rows="15" id="ud_news"><? echo $news; ?></textarea> </p> <p>   <input name="Update" type="Submit" id="Update" value="Update"> </p> </form> <p> <? ++$i; } ?> </p> <form name="form1" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> News ID Number: <input name="id" type="text" id="id" size="3" maxlength="3"> <input name="Get" type="submit" id="Get" value="Get"> </form> <p>&nbsp; </p> <?php if ($_POST['Update']) { require("connect.php"); $id=$_GET['id']; $ud_title = $_POST['ud_title']; $ud_news = $_POST['ud_news']; $query = "UPDATE news SET id='$id', title='$ud_title', news='$ud_news'"; mysql_query($query); echo "The News Article: <b>$ud_title</b> ID: <b>$id</b> has been updated"; mysql_close(); } ?> [/code] You guys will probally say its something really simple but i cant find it anywhere. Many Thanks Glen
×
×
  • 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.