Jump to content

Using a GET variable in Java script


CloudBreaker
Go to solution Solved by QuickOldCar,

Recommended Posts

I'm trying to pass the ID variable on to the next page with no luck.  Line 74 is my attempt.

 

thanks,

CB

<?php
include_once 'dbconfig.php';
?>
<?php
session_start(); 

	if(!$_SESSION['user_loginName']){
	header("location: index.php");
	}
	else {

	$project_id=$_SESSION['project_id'];	
	
	
	if(isset($_GET['id']) && is_numeric($_GET['id'])){
	
	
	$no = $_GET['id'];
	
	//grab discipline
	$name = $_SESSION['firstName'];
	
	
	$sel = "SELECT * FROM hsa_users WHERE user_firstName='$name'";
	$run = mysqli_query($conn, $sel);
	
	$row=mysqli_fetch_array($run);{
		$discipline	= $row['user_discipline'];
	//End of grab discipline	
	}
	//grab RFI No.
	$s = "SELECT * FROM rfis WHERE no='$no'"; //note...it doesn't have to be $sql everytime.
	$run = mysqli_query($conn, $s);
	
	$row=mysqli_fetch_array($run);{
		$rfiNo = $row['name'];
		}
	//end of grab RFI No.
		
	
	 
	}

?>
<?php
if(isset($_POST['btn-upload']))
	

{    
     
	$file 		= rand(1000,100000)."-".$_FILES['file']['name'];
    $file_loc 	= $_FILES['file']['tmp_name'];
	$file_size	= $_FILES['file']['size'];
	$file_type 	= $_FILES['file']['type'];
	$folder		="rfi_files/";
	
	// new file size in KB
	$new_size = $file_size/1024;  
	// new file size in KB
	
	// make file name in lower case
	$new_file_name = strtolower($file);
	// make file name in lower case
	
	$final_file=str_replace(' ','-',$new_file_name);
	
	if(move_uploaded_file($file_loc,$folder.$final_file))
	{
		$sql="INSERT INTO rfi_files(no,file,type,size) VALUES('$no','$final_file','$file_type','$new_size')";
		mysqli_query($conn,$sql);
		?>
		<script>
		alert('successfully uploaded');
        window.location.href='rfi-files.php?id=<?php echo $edit_id;?>success';
        </script>
		<?php
	}
	else
	{
		?>
		<script>
		alert('error while uploading file');
        window.location.href='rfi-upload.php?fail';
        </script>
		<?php
	}
}
?>

<?php } ?>   
Link to comment
Share on other sites

There isn't any $edit-id variable, I see a possible $no or $project_id can use.

 

You can do this with header() instead, even with a message and delay if wanted to.

 

Additionally use exit; after header() so the rest of the script does not continue.

$no is the value I would like to pass to the next page which is rfi-files.php

 

thnx

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.