herghost Posted April 19, 2009 Share Posted April 19, 2009 Hi all, I am wondering if AJAX is what I need here. I have a link which users java to open a page in a popup box, here is an example code: <a href="bandpic.php" title="Upload Band Picture" onClick=" Modalbox.show(this.href, {title: this.title, width: 600}); return false; ">Upload Band Picture</a> It uses protype.js and modelbox.js These are to large to paste here but I can add them as an attachment if it helps Once the page has been loaded, it adds information to a database like so: <?php //Start session session_start(); //Include database connection details require_once('../include/database.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $userid = $_SESSION['SESS_USERID']; $bandname = $_SESSION['SESS_BANDNAME']; $genre = clean($_POST['genre']); $formed = clean($_POST['formed']); $member0 = clean($_POST['member0']); $member1 = clean($_POST['member1']); $member2 = clean($_POST['member2']); $member3 = clean($_POST['member3']); $member4 = clean($_POST['member4']); $member5 = clean($_POST['member5']); $position0 = clean($_POST['position0']); $position1 = clean($_POST['position1']); $position2 = clean($_POST['position2']); $position3 = clean($_POST['position3']); $position4 = clean($_POST['position4']); $position5 = clean($_POST['position5']); //Input Validations if($formed == '') { $errmsg_arr[] = 'Year Formed is Missing'; $errflag = true; } $sql = mysql_query("SELECT * FROM banddata WHERE userid = '$userid'"); if(mysql_num_rows($sql) == 0) { //Create INSERT query $qry = "INSERT INTO banddata (userid, bandname, genre, formed, position0, member0, position1, member1, position2, member2, position3, member3, position4, member4, position5, member5) VALUES ('$userid','$bandname','$genre', '$formed', '$position0', '$member0','$position1', '$member1', '$position2', '$member2','$position3', '$member3','$position4', '$member4', '$position5', '$member5')"; } else { //Create update query $qry = "UPDATE banddata SET bandname = '$bandname', genre = '$genre', formed = '$formed', position0 = '$position0', member0 ='$member0', position1 = '$position1', member1= '$member1', position2 = '$position2', member2 ='$member2', position3 = '$position3', member3 ='$member3', position4 = '$position4', member4 ='$member4', position5 = '$position5', member5 = '$member5' WHERE userid = '$userid'"; } $result = mysql_query($qry) or die(mysql_error()); // list all field you want to be added to your session $fields = array('genre', 'formed', 'position0', 'member0', 'position1', 'member1', 'position2', 'member2', 'position3', 'member3', 'position4', 'member4', 'position5', 'member5'); // here we define the session variable for each field foreach($fields as $var) { if(isset($_POST[$var])) $_SESSION[$var] = $_POST[$var]; } //Check whether the query was successful or not if($result) { header("location: ../member_home.php"); exit(); }else { die(mysql_error()); } ?> As you can see, once the script has completed it uses header("location: ../member_home.php"); exit(); What I want is a message to popup when you return to say upload succesful or something along them lines, how would I go about this? Thanks Quote Link to comment Share on other sites More sharing options...
jackpf Posted April 19, 2009 Share Posted April 19, 2009 Just do header('Location: member_home.php?update=1'); //then on the member_home.php if(isset($_GET['update'])) { echo '<script>....etc } Quote Link to comment Share on other sites More sharing options...
herghost Posted April 20, 2009 Author Share Posted April 20, 2009 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.