Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # Function to connect with the database.
- function connect(){
- mysql_connect("localhost","ehab","ehab") or die(mysql_error());
- mysql_select_db("ehab") or die(mysql_error());
- }
- # Function to close the database connection.
- function destroy(){
- mysql_close();
- }
- function update_profile($username){
- connect();
- if(isset($_POST['update'])){
- #Make the changes in the database
- mysql_query("UPDATE users SET email = '".$_POST["email"]."' WHERE email = '$username'") or die(mysql_error());
- mysql_query("UPDATE users SET fname = '".$_POST["fname"]."' WHERE email = '$username'") or die(mysql_error());
- mysql_query("UPDATE users SET lname = '".$_POST["lname"]."' WHERE email = '$username'") or die(mysql_error());
- mysql_query("UPDATE users SET country = '".$_POST["country"]."' WHERE email = '$username'") or die(mysql_error());
- mysql_query("UPDATE users SET city = '".$_POST["city"]."' WHERE email = '$username'") or die(mysql_error());
- #Check if the password needs changing
- if(!empty($_POST['password'])){
- #Check for a minimum length of the password
- if(strlen($_POST['password']) < 6){
- echo '<p><span class="error">Password has not been updated. Must be minimum 6 characters!</span> <a href="editprofile.php">Go back</a></p>';
- }else{
- #Update the password
- mysql_query("UPDATE users SET password = '".md5($_POST["password"])."' WHERE email = '$username'") or die(mysql_error());
- }
- }
- #Update the session information
- $_SESSION["admin"] = $_POST["email"];
- echo '<p>Profile has been updated!</p>';
- }else{
- #Get all the user information and display it.
- $user = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE email = '$username'"));
- echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
- <table id="hor-zebra" style="width: 80%;">
- <tbody>
- <tr class="odd">
- <td>E-mail</td>
- <td><input type="text" name="email" value="'.$user['email'].'" /></td>
- </tr>
- <tr>
- <td>Password</td>
- <td><input type="password" name="password" value="'.$user['password'].'" /> <span style="font-size: 0.8em;">(Leave blank to keep current password)</span></td>
- </tr>
- <tr class="odd">
- <td>First name</td>
- <td><input type="text" name="fname" value="'.$user['fname'].'" /></td>
- </tr>
- <tr>
- <td>Last name</td>
- <td><input type="text" name="lname" value="'.$user['lname'].'" /></td>
- </tr>
- <tr class="odd">
- <td>Country</td>
- <td><input type="text" name="country" value="'.$user['country'].'" /></td>
- </tr>
- <tr>
- <td>City</td>
- <td><input type="text" name="city" value="'.$user['city'].'" /></td>
- </tr>
- <tr>
- <td><img src="img/reg_arrow.gif"></td>
- <td><input type="submit" value="Update Profile" name="update" /></td>
- </tr>
- </tbody>
- </table>
- </form>';
- }
- destroy();
- }
- function addmodule($go,$error){
- if($go == "Success"){
- echo '<p>Audio file has been successfully uploaded, now it\'s time to <a href="addcontent.php?mp3='.$error.'">add content</a> or <a href="addproject.php?go=Another&error='.$error.'">add another audio file</a>.';
- }
- if($go == "Another"){
- echo '<p>Please upload another audio file.</p>';
- echo '<form enctype="multipart/form-data" method="post" action="upload.php?error='.$error.'" onsubmit="startUpload();">
- <p id="f1_upload_process" style="visibility: hidden; text-align: center;">Uploading...<img src="loader.gif" /></p>
- <p id="f1_upload_form" align="center"><br/>
- <label><input type="hidden" name="amount" type="text" id="amount" /></label>
- <label>File: <input name="myfile" type="file" size="30" /></label>
- <label><input type="submit" name="submitBtn" value="Upload" /></label>
- </p>
- </form>';
- echo '<div><p>Audio files uploaded so far: <br />';
- print "<ul>";
- $songs = explode("***", $error);
- for($i=0;$i<count($songs);$i++){
- echo "<li>".$songs[$i]."</li>"; //Hier nog de remove option
- }
- echo '</p></div>';
- }
- if($go == "Error" || empty($go)){
- echo '<p>Please upload an audio file.</p>';
- echo '<form enctype="multipart/form-data" method="post" action="upload.php" onsubmit="startUpload();">
- <p id="f1_upload_process" style="visibility: hidden; text-align: center;">Uploading...<img src="loader.gif" /></p>
- <p id="f1_upload_form" align="center"><br/>
- <label><input type="hidden" name="amount" type="text" id="amount" /></label>
- <label>File: <input name="myfile" type="file" size="30" /></label>
- <label><input type="submit" name="submitBtn" value="Upload" /></label>
- </p>
- <p><span class="error">'.$error.'</span></p>
- </form>';
- }
- }
- function show_add_module_form($mp3){
- if(!$_POST){
- echo '<p>The audio file has been successfully uploaded and will be inserted automaticly within the content. Now you have to add the content.</p>';
- echo '<form action="addcontent.php" method="post">
- <input type="hidden" value="'.$mp3.'" name="mp3" />
- <input type="text" value="Name of module?" name="modulename" />
- <p>
- <textarea class="ckeditor" cols="80" id="editorcontent" name="editorcontent" rows="10"><p>This is some <strong>sample text</strong>.</textarea>
- </p>
- <p>
- <input type="submit" value="Submit" name="submitcontent"/>
- </p>
- </form>';
- }else{
- $econtent = $_POST["editorcontent"];
- $songs = explode("***", $_POST["mp3"]);
- $amount = count($songs);
- for($i=0;$i<count($songs);$i++){
- $econtent.= "<p>\n".$songs[$i]."</p>\n";
- //echo $songs[$i]." <br />";
- }
- $modulename = $_POST["modulename"];
- connect();
- mysql_query("INSERT INTO modules VALUES (null,'$modulename','$econtent')");
- echo '<p>Module has been created with success!</p>';
- destroy();
- }
- }
- function footer(){
- //To be added
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement