Jump to content

ccmcs

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ccmcs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I've fixed it I'm not sure it's the best way to do it but I've included the div in the echo statement and it seems to be working fine, I was just having a problem with quotations in the html code within the echo command!
  2. is dreamweaver a swear word around here? That highlights everything nicely... (awaits possible backlash?!)
  3. Hi, I've done some serious google'ing... I'm all googled out and it doesn't appear there is a solution to this the way I'm attempting it and it's probably more a case of my early ventures into development that I'm missing something that may or may not be a better and if not more obvious way to do this... Here's the principle, Customer Logs into webpage - greeted by profile page (all cushty so far) - Can choose to move to view 'audio files' which relate to the products they have purchased (this is where it gets silly...) The idea is that both the profile page and the audio page are controlled by a $_SESSION within PHP scripting so the pages are dynamic. I want to include all of the audio files for every product on the 'audio.php' page BUT I only want the ones that they have purchased to be visible... All the setup is fine because the following works fine: if($info['halftimerock'] == 1) { echo "<p>Half Time Rock</p>";} Which essentially checks the db, finds a 1 in the appropriate product and displays the name of the product in a list, if no products then nothing in the list etc. What I want to do is control the visibility of some <div>'s using the same kind of idea, so: if($info['halftimerock'] == 1) { CODE TO DISPLAY DIV IN HERE } I have a 'toggleelement' JS function available which works for mouse clicks but obviously php and js don't exactly go well together so that is probably not the way to go, I'm already running a lot of PHP at the top of the page before the HTML to stop session header errors. A couple of web searches have suggested I insert a <script> tag into the echo command but I can't get that to work and I guess it's a really messy way of trying to do things! So here's the question, any ideas about how to toggle <div> visibility within php or is that purely something for js to handle?... Is there a better/cleaner way of doing it all, perhaps redirecting users to different pages based on their entries in the DB (which could all be handled with headers but I'll end up with a million different pages and combinations eventually? I could always create a .htaccess/.htpasswd file system and handle the folders with audio content in manually so that all files are visible but only a valid username and password will be able to access the file but that's going to get annoying for people having to put in user/pass for every file and also for me updating the users for each individual file every time some1 buys something... Any ideas? Anybody done anything similar? Cheers
  4. depends what the format of your ID is but can you not just use the AUTO_INCREMENT feature on the id column of the DB?
  5. are all your strings setup above the bit you pasted in? $user_id etc
  6. The best way to do it in all honesty is use the scripting that you paid for, have a look through it and see if you can follow each bit, I've hardly done any PHP but managed to get a working login system etc uploaded from bits off the internet and then reading the php manual on-line that describes each function/command/variable etc... Load it up you must have all the scripts and sections if you are hosting the site?
  7. This is the script I am trying to use for the above, I've obviously taken out passwords etc (CAPS are replacements) but they are definitely correct and throwing up no errors, I've copied them from other scripts, I'm thinking that the problem could be to do with $_SESSION pull throughs from the other page but I'm not sure, is there a way to include the PHP for the script directly in the other file in the form and self action it? I was trying to keep things neater with seperate files, the profile.php is already riddled with js/php/html all over the shop! Anybody any ideas? basically the only button the form has is "change_email_submit" and the text field is "change_email" but you'll be able to see that from the code. <?php // Connects to the DB $link = mysql_connect('localhost', 'USER', 'PASS') or die("I couldn't connect to your database, please make sure your info is correct!"); mysql_select_db('DBNAME') or die("Database cannot be found"); if(!isset($link)) { echo "Connection Error:" mysql_error(); } // gathers existing e-mail from session $email = $_SESSION['email']; // Gathers new e-mail address from form $new_email = mysql_real_escape_string($_POST['change_email']) or die (mysql_error()); // Sets up username for session $user = $_SESSION['username']; // Sets up command to update record in DB $update = mysql_query("UPDATE users SET email='$new_email' WHERE username='$user'", $link); if(!isset($update)) { echo "Sorry but there has been an error, your e-mail address cannot be changed at this time, please contact E-MAIL ADDRESS to have your e-mail address altered manually."; } else { header('Location: PROFILEPAGE'); } ?> FORM CODE(extracted from another file): <div id="change_email_form" style=""> <form name="change_email_form" action="change_email.php" method="post"> <label for="change_email"> <div align="center">Please enter new e-mail address in the box below:</div> </label> <div align="center"> <input name="change_email" type="text" size="60" /> <input type="submit" value="Update Email" name="email_change_submit" /> </div> </form>
  8. thanks for the responses, I am using $_SESSION setups for username etc, I had a a problem with that format before tho because the info didn't seem to be retained across different scripts but I think that was only when scripts were in different folders on the server, I am not at the desk at the moment but I will try post the script asap, cheers again
  9. Hi, I've been scratching my head for a while now about how to do this, I'm relatively new to php and mysql and perhaps foolishly taking on creating a user area for a website. I have everything else working, all of my register account functions and confirmations and all of the login scripts etc. I have created a profile page which returns various information to the user (this bit works fine) and I've got some nice show/hide toggles running with some javascript/css but my intention is to allow the user to change thier information (e-mail address, contact phone number and also whether they are subscribed to the e-mail list), it also displays any support tickets or messages. So after the long intro, here's what I'm struggling with... I have a form in a visibility toggled <div> which submits a 'change_email' script, so a user wants to change their e-mail, clicks on change, the <div> appears, they bang in the new e-mail and hit submit. My php script appears to work (because it doesn't throw up any errors), until you realise that actually it's not updated the record in the db... I'm using mysql_query("UPDATE users SET email='$new_email' WHERE username='$user'"); Do I need to setup variables for all of the information in the db (name, username, password, email, contno etc etc) and include them in the command to get it to work or should that just pick the correct record and then update it? If that is the case is there a way I can include 'blank' variables so I don't have to set them all up... e.g. mysql_query("UPDATE users SET user='',password='',email='$new_email', etc WHERE username='$user'"); Many thanks in anticipation
×
×
  • 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.