Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8952233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:49:54+00:00 2026-06-15T13:49:54+00:00

Hi anyone I want to pass value from php to c by use php

  • 0

Hi anyone I want to pass value from php to c by use php value as argument to run c program but c program can’t be seen any value from php

This code of php :

    enter code here
<form action="create.php" method="post">
Create VM on website <br>
VM Name 
    <input type="text" name="vm_n" value="" />
VM Ram
    <input type="text" name="vm_r" value="" />
VM Virtual CPU
    <input type="text" name="vm_c" value="" />
VM File size 
    <input type="text" name="vm_fs" value="" />
VM File OS
    <input type="text" name="vm_b" value="" />
    <input type="submit" name="button1" value="Submit" />
</form>
<?php
 //Check wihch Submit was clicked and pass from php
$vm_n[10]=$_POST['vm_n'];                                
$vm_r[5]=$_POST['vm_r'];
$vm_c[3]=$_POST['vm_c'];
$vm_fs[5]=$_POST['vm_fs'];
$vm_b=[8]$_POST['vm_b'];
if ($_POST['button1']) {
    echo "Creating VM.......";
    $last_line = system('/var/local/vmweb/create_vm install -n $vm_n -r $vm_r -c $vm_c -fs $vm_fs -b $vm_b', $retval);
    echo '
    </pre>
    <hr />Status Output: ' . $last_line . '
    <hr />Status Output: ' . $vm_n . '
    <hr />Status Output: ' . $vm_r . '
    <hr />Status Output: ' . $vm_c . '
    <hr />Status Output: ' . $vm_fs . '
    <hr />Status Output: ' . $vm_b . '
    <hr />Return value: ' . $retval;

} 
?>
and this code of C program : 
if (!(initsetuid())){
        exit(1);
    }
    // Check what command is asked
    if (argc==1)
    {       
        fprintf (stderr, "Missing Agument to Create VM command!\n");
        return 1;
    }
    if (argc==12 && strcmp(argv[1], OP_INSTALL)==0) {
        if (argc==12 && strcmp(argv[2], "-n")==0)   {
    printf("Argument is : %s Parameter is: %s \n", argv[2],argv[3]);        
    sprintf (vm_name,argv[3]);  
    //printf("vm_name is : %s \n",vm_name);
    }

I’m use if else to catch some argument on string

need you help me please !! thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:49:55+00:00Added an answer on June 15, 2026 at 1:49 pm

    In this line

    system('/var/local/vmweb/create_vm install -n $vm_n -r $vm_r -c $vm_c -fs $vm_fs -b $vm_b', $retval);
    

    You are using single quotes to surround variables in the string, PHP doesn’t work that way. Use double quotes instead.

    system("/var/local/vmweb/create_vm install -n $vm_n -r $vm_r -c $vm_c -fs $vm_fs -b $vm_b", $retval);
    

    Also I think you’ve missed out an ‘=’ here: You’ve put the ‘=’ in the wrong place:

    $vm_b=[8]$_POST['vm_b'];
    

    Should be:

    $vm_b[8] = $_POST['vm_b'];
    

    Wait a minute!

    I think all of this bit is wrong!

    $vm_n[10]=$_POST['vm_n'];                                
    $vm_r[5]=$_POST['vm_r'];
    $vm_c[3]=$_POST['vm_c'];
    $vm_fs[5]=$_POST['vm_fs'];
    $vm_b=[8]$_POST['vm_b'];
    

    You are creating arrays with the above code, and I don’t believe that’s really what you want..

    Try this instead:

    $vm_n = $_POST['vm_n'];                                
    $vm_r = $_POST['vm_r'];
    $vm_c = $_POST['vm_c'];
    $vm_fs = $_POST['vm_fs'];
    $vm_b = $_POST['vm_b'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass a value from PHP to C++. I think I can
I want to pass value from block but I am unable to get the
I want to generate graph from my database data can anyone tell me about
I want to know how to pass value from ajax function to another ajax
hello i want to pass the value of a function to any other function
Anyone want to take a stab at why this bookmarklet fails in IE8? It
I don't want anyone saying you should not reinvent the wheel, use an open
I want to trial Windows 7 but wondered if anyone who has done so
I want to develop android based application in c#.Can anyone tell me where can
I want to Integrate Weather radar on my MapView.Please anyone help on doing this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.